Files
scriptc/tests/corpus/2794-array-generic-callback-values.ts
Chris Tate 94fd361b54 Implement sparse native arrays and missing-value parity (#297)
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
2026-09-12 22:39:07 -05:00

15 lines
641 B
TypeScript

// Generic callback values remain generic until each HOF call supplies a
// concrete signature. The optional-array prepass must not ask the generic
// parameter for a monomorphic ABI too early.
const identity = <T>(value: T): T => value;
const pair = <A, B>(left: A, right: B): string => `${left}|${right}`;
const numberIdentity = identity<number | undefined>;
console.log([1, 2, 3].map(numberIdentity).join("+"));
console.log([1, 2, 3].filter((value) => value > 1).join(","));
console.log([1, 2, 3].reduce((sum, value) => sum + value, 0));
console.log(pair(7, "seven"));
const f: (value: number) => number = identity;
console.log(f(41));