mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-03 07:54:40 +08:00
Co-authored-by: dolphin278 <1130473+dolphin278@users.noreply.github.com> Fixes #2139 Fixes #2131 Fixes #2132 Fixes #2133 Fixes #2140 Fixes #2141 Fixes #2159
13 lines
375 B
TypeScript
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 {};
|