Created
November 14, 2022 18:14
-
-
Save alxpsr/189a49ec362215574ffc322e595c30e8 to your computer and use it in GitHub Desktop.
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
const User = { | |
id: 123, | |
username: 'John', | |
email: '[email protected]', | |
addons: [ | |
{ name: 'First addon', id: 1 }, | |
{ name: 'Second addon', id: 2 } | |
] | |
} | |
type UnpackArray<T> = T extends (infer R)[] ? R : T | |
type AddonType = UnpackArray<typeof User.addons> // { name: string, id: number } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment