-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
Description
TypeScript Version: 3.5.1, 3.6.3, Nightly (2019-09-24)
Search Terms:
Tuple, spread, assignability
Code
declare const src : [number, ...number[]];
const [head, ...tail] = src;
//Expected: OK
//Actual : OK
const dst0 : [number, ...number[]] = [head, ...tail];
//Expected: OK
//Actual : Error
//Property '0' is missing in type 'number[]' but required in type '[number, ...number[]]'.
const dst1 : [number, ...number[]] = [head, ...tail, 1337];Expected behavior:
Assignment to dst1 should succeed.
It should succeed because head is number and ...tail, 1337 should correspond to ...number[]
Actual behavior:
Assignment to dst1 fails.
Playground Link:
Related Issues:
Possibly this,
#29248
It mentions spread arguments, and an extra argument at the end causes TS to not realize there are the right number of arguments.
However, this repro just has tuples not being assignable to other tuples.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript