Skip to content

Instantly share code, notes, and snippets.

@y21
Created August 29, 2020 11:06
Show Gist options
  • Save y21/3e67e4f71b8b99d684f86e4af2a363ab to your computer and use it in GitHub Desktop.
Save y21/3e67e4f71b8b99d684f86e4af2a363ab to your computer and use it in GitHub Desktop.
type Value = string | number;
type Indexable<V> = { [key: string]: V };
function makeTypedNullPrototype<T = any, V = Value>(obj: T): T & Indexable<V> {
return Object.setPrototypeOf(obj, null);
}
// const p = makeTypedNullPrototype({
// a: 3
// });
// console.log(
// p[prompt()!]
// );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment