mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
- 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>
24 lines
905 B
TypeScript
24 lines
905 B
TypeScript
// Function values whose defaulted parameter the checker types `any`: under
|
|
// an `(...args: any[]) => any` wrapper slot the contextual `any` wins over
|
|
// the default's type. The callable's slot is the checked-dynamic value the
|
|
// body already reads.
|
|
function traced<F extends (...args: any[]) => any>(name: string, fn: F): F {
|
|
console.log("wrap", name);
|
|
return fn;
|
|
}
|
|
|
|
function configured(raw = process.env["SCRIPTC_TEST_UNSET_WIDTH"]): number | undefined {
|
|
const width = Number.parseInt(raw ?? "", 10);
|
|
return Number.isSafeInteger(width) && width > 0 ? width : undefined;
|
|
}
|
|
|
|
const layout = traced("layout", (width = configured() ?? 80) => {
|
|
return { width, gutter: 2 };
|
|
});
|
|
console.log(JSON.stringify(layout()), JSON.stringify(layout(120)));
|
|
|
|
const scaled = traced("scaled", function (factor = 2, base = 10) {
|
|
return base * factor;
|
|
});
|
|
console.log(scaled(), scaled(3), scaled(undefined, 1));
|