Created
November 21, 2019 13:24
-
-
Save yamafaktory/c8a9296c18e2d5be9e0021e24e1f3bde to your computer and use it in GitHub Desktop.
π Typecheck object properties from array elements in TypeScript
This file contains hidden or 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
const MY_ARRAY = ['a', 'b', 'c'] as const | |
const objectWithKeysFromConstArrayElements: Record< | |
typeof MY_ARRAY[number], | |
string | |
> = { a: 'foo', b: 'bar', c: 'foobar' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment