Files
scriptc/tests/corpus/6471-any-method-chains.ts
T
Malte UblandClaude Opus 5.5 37551e41b4 Compile any crossings: destructuring, namespace patterns, any parameters and async callbacks
- Destructuring an `any` value in TypeScript (a function typed `any`, an
  awaited `any`, `JSON.parse`, an `any` table read) now goes through the
  checked-dynamic value, as JavaScript sources and #1407's JS-declared
  results already did. Object sources get V8's RequireObjectCoercible
  TypeError for the spellings the assignment form reproduces.
- A method call or member read on a checker-`any` receiver whose value is
  a fresh typed call result (`out.split("\n").map(...)`, `.pop()`,
  `.length`) boxes that temporary and dispatches on the runtime kind,
  only after every other lowering declined.
- `const { a, b: c } = ns` and `= await import("./m")` over a program
  module bind each export the way `ns.a` reads it.
- A defaulted parameter of a program-source function, arrow or function
  expression that the checker types `any` (a default under an
  `(...args: any[]) => any` wrapper slot, where the contextual `any`
  wins) is a dyn ABI slot in the callable's type.
- An async lambda whose signature answered a bare dyn result (a library
  slot `A | Promise<A>` with A = any) produces Promise<unknown>.
- `761-any-objects` compiles and moves back to the corpus; the
  retired-engine 2083/2104 snapshots shrink to their remaining fences.
- JavaScript `Promise.resolve(value)` (in a JavaScript file) over a dyn value holding a promise
  answers that promise instead of wrapping it, so a TypeScript async
  callback's result is adopted by JavaScript retry helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 00:30:58 -07:00

25 lines
886 B
TypeScript

// Method chains over `any`-derived strings: each step that answers a fresh
// native value (split's string[]) keeps chaining through the
// checked-dynamic value — map, filter(Boolean), pop, join — and the result
// checks back into typed slots.
function exec(): any {
return { stdout: " 3f2a\n 9c1b \n\n77de\n", stderr: "warn: shallow\n" };
}
const { stdout, stderr } = exec();
let ids: string[] = [];
ids = stdout
.split("\n")
.map((s: string) => s.trim())
.filter(Boolean);
console.log(ids.length, ids.join(", "));
const last: string = stdout.trim().split("\n").pop() ?? "";
console.log(JSON.stringify(last));
const firstWord: string = stderr.trim().split(":")[0];
console.log(firstWord, stderr.trim().split(" ").length);
const words: string[] = stdout.trim().split(/\s+/);
console.log(words.length, stdout.split("\n").length, stdout.trim().split("\n").join("|"));