Last active
June 18, 2020 10:38
-
-
Save jamesseanwright/36c70bc8a37bfee2676b05b2e341666a to your computer and use it in GitHub Desktop.
Example of variadic kinds in TypeScript, landing in version 4.0
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 concat = <...TInput, ...TItems>( | |
| input: ...TInput, | |
| ...appendees: ...TItems, | |
| ): [...TInput, ...TItems] => [...input, ...appendees]; | |
| const x = concat([1, 2], '3', { no: 4 }); // [1, 2, '3', { no: 4 }] | |
| typeof x; // [number, number, string, { no: number }] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment