Created
June 29, 2021 22:20
-
-
Save AitorAlejandro/75b6d40d98624fec84f6089a19860487 to your computer and use it in GitHub Desktop.
Using the keyof operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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