Skip to content

Instantly share code, notes, and snippets.

@alxpsr
Created November 14, 2022 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alxpsr/189a49ec362215574ffc322e595c30e8 to your computer and use it in GitHub Desktop.
Save alxpsr/189a49ec362215574ffc322e595c30e8 to your computer and use it in GitHub Desktop.
const User = {
id: 123,
username: 'John',
email: 'john@mail.com',
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