Files
scriptc/tests/diagnostics/overloaded-function-values.ts
T
Chris Tate 44cde1510e Split the SC2001 catch-all into named type-fence families
- New codes, minted in badType's classification order: SC2005 values whose type keeps a generic call signature, SC2006 index-signature shapes outside the supported set, SC2007 overloaded function types, SC2008 intersections with no resolved lowering, SC2009 supported container/function/record shapes over a component outside its slot — the SC2009 message names the offending component (Map/Set key-value domains, array/tuple elements, union arms, function rest/params/returns, record members) via describeComponentBlocker/describeRecordMemberBlocker in frontend/types.ts, which mirror mapType's own rules on the failure path only.
- Standard-library nominal types with no lowering at all (Date, ArrayBuffer, WeakMap, the iterator and constructor interfaces) now route to the existing SC2020 story instead of the supported-set recitation; stdlib provenance is checked after the container claims so Map/Set/Promise instantiation failures keep their component story.
- SC2001 keeps the honest remainder — bigint and symbol primitives, constructor objects, and library-derived or unresolved generic shapes — and its registry name now says so; across the diagnostics corpus its rendered sites drop from 57 to 5.
- Every new code flows through the diagnostics registry, the regenerated surface manifest, and coverage-report grouping; five new tests/diagnostics programs pin one rendered frame per code, and the ts7 order-parity baselines re-record to include them.
- Zero behavior change to accepted programs: the differential corpus (900 programs) is untouched and green, and the full suite passes.
2026-07-23 16:55:31 -05:00

17 lines
597 B
TypeScript

// SC2007: values of overloaded function type — a compiled function VALUE is
// one concrete signature. Calls of overloaded declarations resolve per call
// site; it is the value position that fences.
function pick(x: "a"): string;
function pick(x: "b"): number;
function pick(x: string): string | number {
return x === "a" ? "A" : 1;
}
const stored = pick;
console.log(stored("a"));
// An overloaded TYPE LITERAL slot fences the same way.
declare const on: { (event: "exit", code: number): void; (event: "error", err: string): void };
const listener = on;
console.log(listener("exit", 0));