-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
I am trying to do a simple spread operator but I am getting typescript errors.
TypeScript Version: 3.8.3
Code
type Vec2 = [number,number];
type Vec4 = [number,number,number,number];
const a: Vec2 = [0,1];
const b: Vec2 = [2,3];
const broken: Vec4 = [...a,...b];
const works: Vec4 = [a[0],a[1],b[0],b[1]];// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.Expected behavior:
I expect this to work. I expect broken and works to both have the value of [0,1,2,3]
Actual behavior:
The broken line gives me this error:
[tsl] ERROR in /mnt/src/main.ts(6,7)
TS2739: Type 'number[]' is missing the following properties from type '[number, number, number, number]': 0, 1, 2, 3
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created