Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Last active June 18, 2020 10:38
Show Gist options
  • Select an option

  • Save jamesseanwright/36c70bc8a37bfee2676b05b2e341666a to your computer and use it in GitHub Desktop.

Select an option

Save jamesseanwright/36c70bc8a37bfee2676b05b2e341666a to your computer and use it in GitHub Desktop.
Example of variadic kinds in TypeScript, landing in version 4.0
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