typescript-book
typescript-book copied to clipboard
Tuple types with spreads
Reader comment https://www.gitbook.com/book/basarat/typescript/discussions/72 :rose: Quote:
If you want a tuple type like
[string, boolean, ...number], you can useinterface YourName extends Array<number> { 0: string, 1: number }
That said, I'm nervous of edge cases. TypeScript has native understanding of tuples that might from its understanding of Array at a future point.
I agree. It would be much better to have [string, boolean, ...number]-style types built into TS!