Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created June 29, 2021 22:20
Show Gist options
  • Save AitorAlejandro/75b6d40d98624fec84f6089a19860487 to your computer and use it in GitHub Desktop.
Save AitorAlejandro/75b6d40d98624fec84f6089a19860487 to your computer and use it in GitHub Desktop.
Using the keyof operator
interface Foo {
bar: number;
baz: string;
qux: Date;
}
type FooKey keyof Foo; // "bar" | "baz" | "qux"
const fooLookUp = (key: FooKey) => foo[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment