type-challenges: 533 - Concat
type Tuple = readonly unknown[];
type Concat<T extends Tuple, U extends Tuple> = [...T, ...U];
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 56
- Comments: 18
type Tuple = readonly unknown[];
type Concat<T extends Tuple, U extends Tuple> = [...T, ...U];
type Concat<T extends readonly unknown[], U extends readonly unknown[]> = […T,…U];
The only issue with this is that
any[]says “any list type that is not readonly”, so this will throw an error:Type 'readonly []' does not satisfy the constraint 'any[]'. The type 'readonly []' is 'readonly' and cannot be assigned to the mutable type 'any[]'. ts(2344)Can somebody provide a reference to docs that explain using the spread operator on types?