Skip to content

Instantly share code, notes, and snippets.

@ztrehagem
Last active September 22, 2023 08:07
Show Gist options
  • Save ztrehagem/7f54b7b76439a9d2aac569518561f011 to your computer and use it in GitHub Desktop.
Save ztrehagem/7f54b7b76439a9d2aac569518561f011 to your computer and use it in GitHub Desktop.
interface ReadonlyMapConstructor {
new <K, V>(entries?: IterableIterator<[K, V]> | null): ReadonlyMap<K, V>;
}
class ReadonlyMapClass<K, V> extends Map<K, V> {}
export const ReadonlyMap: ReadonlyMapConstructor = ReadonlyMapClass;
//
const readonlyMap = new ReadonlyMap<string, number>();
readonlyMap.get("foo");
readonlyMap.set("foo", 1); // type error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment