Files
scriptc/tests/diagnostics/untyped-map-into-interface.ts
T
2026-10-26 01:50:59 -05:00

13 lines
375 B
TypeScript

// An untyped `new Map()` satisfies a record interface only through `any`;
// its flow into the interface-typed result is refused at build time, like a
// typed Map is.
interface Cache {
get(key: string): number | undefined;
set(key: string, value: number): unknown;
}
function make(c?: Cache): Cache {
return c ?? new Map();
}
console.log(make().get("a"));
export {};