Created
November 14, 2022 18:14
-
-
Save alxpsr/189a49ec362215574ffc322e595c30e8 to your computer and use it in GitHub Desktop.
Revisions
-
alxpsr created this gist
Nov 14, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ 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 }