Reputation: 3130
Say I have a Typescript tuple:
type Sandwich = [name: string, toppings: object]
Now I want to extend it:
type HotDog = [name: string, toppings: object, length: number]
Can HotDog
extend Sandwich
without duplication?
Upvotes: 1
Views: 180
Reputation: 187024
Just spread one into the other:
type Sandwich = [name: string, toppings: object]
type HotDog = [...sandwich: Sandwich, length: number]
// ^ type is [name: string, toppings: object, length: number]
Upvotes: 2