typescript-book icon indicating copy to clipboard operation
typescript-book copied to clipboard

Tuple types with spreads

Open basarat opened this issue 7 years ago • 2 comments

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 use interface YourName extends Array<number> { 0: string, 1: number }

basarat avatar Dec 06 '17 23:12 basarat

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.

basarat avatar Dec 06 '17 23:12 basarat

I agree. It would be much better to have [string, boolean, ...number]-style types built into TS!

j-f1 avatar Dec 07 '17 00:12 j-f1