mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
* Fix Record array index property reads (#400) - Narrow optional record receivers before keyed reads. - Cover present and missing rows with differential tests. * Record TypeScript 7 baseline for Record array fixture - Add the new corpus program to the preflight and module order baseline. * Stabilize HTTP timeout differential fixtures - Release server responses after timeout callbacks. - Bound missing callbacks with fallback responses.
21 lines
418 B
TypeScript
21 lines
418 B
TypeScript
type Row = Record<string, string | number | null>;
|
|
|
|
function firstId(rows: Row[]): number {
|
|
return rows[0].id as number;
|
|
}
|
|
|
|
console.log(firstId([{ id: 1 }]));
|
|
|
|
let evaluations = 0;
|
|
function makeRows(): Row[] {
|
|
evaluations++;
|
|
return [{ id: evaluations }];
|
|
}
|
|
console.log(makeRows()[0].id, evaluations);
|
|
|
|
try {
|
|
firstId([]);
|
|
} catch (error) {
|
|
console.log(error instanceof TypeError, (error as Error).message);
|
|
}
|