Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variadic tuple types #39094

Merged
merged 37 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7410ac9
Initial implementation of variadic tuple types
ahejlsberg Jun 1, 2020
e5d6be7
Accept new baselines
ahejlsberg Jun 1, 2020
6d6bf6d
Handle variadic elements in tuple type inference
ahejlsberg Jun 4, 2020
5679f36
Special case inference between tuples with matching structure
ahejlsberg Jun 4, 2020
94dd625
Restore check that rest element is last element
ahejlsberg Jun 4, 2020
8669342
Handle variadic tuples in relationship checking
ahejlsberg Jun 7, 2020
34fd780
Accept new baselines
ahejlsberg Jun 7, 2020
e8466d7
Infer readonly constraints when inferring from readonly tuples
ahejlsberg Jun 8, 2020
20eb59e
Fix lint issues
ahejlsberg Jun 8, 2020
54d7d40
T assignable to readonly [...T] and [...T] assignable to T
ahejlsberg Jun 8, 2020
d2b3128
Consistent tuple normalization
ahejlsberg Jun 8, 2020
5902c21
Create variadic tuple types from array literal expressions
ahejlsberg Jun 8, 2020
5d78ed1
Accept new baselines
ahejlsberg Jun 8, 2020
b6b9d4a
Array literals have tuple types when contextual type is readonly
ahejlsberg Jun 9, 2020
0a7c6a9
Accept new baselines
ahejlsberg Jun 9, 2020
97184ab
Optional elements before required elements become required elements
ahejlsberg Jun 9, 2020
7449a6b
Update logic for rest parameters and spread arguments
ahejlsberg Jun 12, 2020
7f0917b
Revert special case of contextual readonly array type
ahejlsberg Jun 12, 2020
0388e8e
Accept new baselines
ahejlsberg Jun 12, 2020
635d440
Fix lint issue
ahejlsberg Jun 13, 2020
32bbd4c
Switch entirely to createTupleType based on element flags
ahejlsberg Jun 13, 2020
10a9eb9
Don't infer readonly tuple types when inferring to variadic elements
ahejlsberg Jun 14, 2020
bb989fc
Handle mapped types applied to generic tuple types
ahejlsberg Jun 14, 2020
fec03a1
Handle constraint of indexed access type with generic tuple type
ahejlsberg Jun 16, 2020
9a04edc
Merge branch 'master' into variadicTuples
ahejlsberg Jun 16, 2020
01d3b54
Accept new baselines
ahejlsberg Jun 16, 2020
2791938
Address CR feedback
ahejlsberg Jun 17, 2020
d37c514
Merge branch 'master' into variadicTuples
ahejlsberg Jun 17, 2020
7593522
Simplify indexed access types involving generic tuple types
ahejlsberg Jun 17, 2020
eb50893
Propagate checkMode into getSpreadArgumentType
ahejlsberg Jun 17, 2020
8f41104
Guard against missing globalArrayType
ahejlsberg Jun 18, 2020
eedf7f1
Inference to [...T, ...U] based on implied arity of T
ahejlsberg Jun 19, 2020
bc04a8d
Merge branch 'master' into variadicTuples
ahejlsberg Jun 19, 2020
aa2c49d
Accept new baselines
ahejlsberg Jun 19, 2020
7bc595b
Add tests
ahejlsberg Jun 20, 2020
0fc28f2
Emit .d.ts from tests
ahejlsberg Jun 22, 2020
11f70be
Address CR feedback
ahejlsberg Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
879 changes: 573 additions & 306 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,14 @@ namespace ts {
return values;
}

export function arrayOf<T>(count: number, f: (index: number) => T): T[] {
const result = new Array(count);
for (let i = 0; i < count; i++) {
result[i] = f(i);
}
return result;
}

/** Shims `Array.from`. */
export function arrayFrom<T, U>(iterator: Iterator<T> | IterableIterator<T>, map: (t: T) => U): U[];
export function arrayFrom<T>(iterator: Iterator<T> | IterableIterator<T>): T[];
Expand Down
20 changes: 20 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,26 @@
"category": "Error",
"code": 2617
},
"Source has {0} element(s) but target requires {1}.": {
"category": "Error",
"code": 2618
},
"Source has {0} element(s) but target allows only {1}.": {
"category": "Error",
"code": 2619
},
"Target requires {0} element(s) but source may have fewer.": {
"category": "Error",
"code": 2620
},
"Target allows only {0} element(s) but source may have more.": {
"category": "Error",
"code": 2621
},
"Element at index {0} is variadic in one type but not in the other.": {
"category": "Error",
"code": 2622
},

"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
"category": "Error",
Expand Down
11 changes: 11 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5088,9 +5088,20 @@ namespace ts {
variances?: VarianceFlags[]; // Variance of each type parameter
}

export const enum ElementFlags {
Required = 1 << 0, // T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are Required and Optional both flags? This means we can mistakenly mark a member as both required and optional, which seems incorrect. Actually, I'm pretty sure all of these are mutually exclusive - is there a good reason this shouldn't be ElementKind instead of ElementFlags?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's similar to TypeFlags and others. Makes it cheaper to check for multiple values at once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the most we use at once is two... Is it really worth giving up exhaustiveness and exclusivity checking to replace so few expressions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this is fine, particularly as the current scheme makes it easy for us to add additional element flags that are orthogonal to the kind of element.

Optional = 1 << 1, // T?
Rest = 1 << 2, // ...T[]
Variadic = 1 << 3, // ...T
Variable = Rest | Variadic,
}

export interface TupleType extends GenericType {
elementFlags: readonly ElementFlags[];
minLength: number;
fixedLength: number;
hasRestElement: boolean;
combinedFlags: ElementFlags;
readonly: boolean;
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2532,9 +2532,19 @@ declare namespace ts {
}
export interface GenericType extends InterfaceType, TypeReference {
}
export enum ElementFlags {
Required = 1,
Optional = 2,
Rest = 4,
Variadic = 8,
Variable = 12
}
export interface TupleType extends GenericType {
elementFlags: readonly ElementFlags[];
minLength: number;
fixedLength: number;
hasRestElement: boolean;
combinedFlags: ElementFlags;
readonly: boolean;
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2532,9 +2532,19 @@ declare namespace ts {
}
export interface GenericType extends InterfaceType, TypeReference {
}
export enum ElementFlags {
Required = 1,
Optional = 2,
Rest = 4,
Variadic = 8,
Variable = 12
}
export interface TupleType extends GenericType {
elementFlags: readonly ElementFlags[];
minLength: number;
fixedLength: number;
hasRestElement: boolean;
combinedFlags: ElementFlags;
readonly: boolean;
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(16,5): error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
Type '(string | number | boolean)[]' is missing the following properties from type '[string, number, boolean]': 0, 1, 2
Target requires 3 element(s) but source may have fewer.
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(17,5): error TS2345: Argument of type '[string, number, true, ...(string | number | boolean)[]]' is not assignable to parameter of type '[string, number, boolean]'.
Types of property 'length' are incompatible.
Type 'number' is not assignable to type '3'.
Target allows only 3 element(s) but source may have more.
tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts(18,5): error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'.
Types of property 'x' are incompatible.
Type '(string | number)[]' is missing the following properties from type '[any, any]': 0, 1
Type '(string | number)[]' is not assignable to type '[any, any]'.
Target requires 2 element(s) but source may have fewer.


==== tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts (3 errors) ====
Expand All @@ -27,14 +27,14 @@ tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextua
baz(array); // Error
~~~~~
!!! error TS2345: Argument of type '(string | number | boolean)[]' is not assignable to parameter of type '[string, number, boolean]'.
!!! error TS2345: Type '(string | number | boolean)[]' is missing the following properties from type '[string, number, boolean]': 0, 1, 2
!!! error TS2345: Target requires 3 element(s) but source may have fewer.
baz(["string", 1, true, ...array]); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[string, number, true, ...(string | number | boolean)[]]' is not assignable to parameter of type '[string, number, boolean]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type '3'.
!!! error TS2345: Target allows only 3 element(s) but source may have more.
foo(o); // Error because x has an array type namely (string|number)[]
~
!!! error TS2345: Argument of type '{ x: (string | number)[]; y: { c: boolean; d: string; e: number; }; }' is not assignable to parameter of type '{ x: [any, any]; y: { c: any; d: any; e: any; }; }'.
!!! error TS2345: Types of property 'x' are incompatible.
!!! error TS2345: Type '(string | number)[]' is missing the following properties from type '[any, any]': 0, 1
!!! error TS2345: Type '(string | number)[]' is not assignable to type '[any, any]'.
!!! error TS2345: Target requires 2 element(s) but source may have fewer.
24 changes: 12 additions & 12 deletions tests/baselines/reference/arityAndOrderCompatibility01.errors.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2493: Tuple type '[string, number]' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2741: Property '2' is missing in type '[string, number]' but required in type '[number, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2741: Property '2' is missing in type 'StrNum' but required in type '[number, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(20,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(21,5): error TS2741: Property '2' is missing in type '[string, number]' but required in type '[string, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(21,5): error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'.
Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(22,5): error TS2741: Property '2' is missing in type 'StrNum' but required in type '[string, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(23,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(24,5): error TS2322: Type '[string, number]' is not assignable to type '[number]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type 'number'.
Source has 2 element(s) but target allows only 1.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error TS2322: Type 'StrNum' is not assignable to type '[number]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'.
Types of property 'length' are incompatible.
Type '2' is not assignable to type '1'.
Source has 2 element(s) but target allows only 1.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'.
Types of property 'length' are incompatible.
Type '2' is not assignable to type '1'.
Expand Down Expand Up @@ -52,7 +52,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
!!! error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type.
var j1: [number, number, number] = x;
~~
!!! error TS2741: Property '2' is missing in type '[string, number]' but required in type '[number, number, number]'.
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Source has 2 element(s) but target requires 3.
var j2: [number, number, number] = y;
~~
!!! error TS2741: Property '2' is missing in type 'StrNum' but required in type '[number, number, number]'.
Expand All @@ -61,7 +62,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, number, number]'.
var k1: [string, number, number] = x;
~~
!!! error TS2741: Property '2' is missing in type '[string, number]' but required in type '[string, number, number]'.
!!! error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'.
!!! error TS2322: Source has 2 element(s) but target requires 3.
var k2: [string, number, number] = y;
~~
!!! error TS2741: Property '2' is missing in type 'StrNum' but required in type '[string, number, number]'.
Expand All @@ -71,8 +73,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
var l1: [number] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[number]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Source has 2 element(s) but target allows only 1.
var l2: [number] = y;
~~
!!! error TS2322: Type 'StrNum' is not assignable to type '[number]'.
Expand All @@ -84,8 +85,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error
var m1: [string] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[string]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '2' is not assignable to type '1'.
!!! error TS2322: Source has 2 element(s) but target allows only 1.
var m2: [string] = y;
~~
!!! error TS2322: Type 'StrNum' is not assignable to type '[string]'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(6,5): error TS2322: Type '[number, number, number, number]' is not assignable to type '[number, number, number]'.
Types of property 'length' are incompatible.
Type '4' is not assignable to type '3'.
Source has 4 element(s) but target allows only 3.
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(7,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[string | number, string | number, string | number]'.
Types of property 'length' are incompatible.
Type '4' is not assignable to type '3'.
Source has 4 element(s) but target allows only 3.
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
Types of property 'length' are incompatible.
Type '4' is not assignable to type '3'.
Source has 4 element(s) but target allows only 3.
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type '[number, number, number, number, number, number]' is not assignable to type '[number, number, number]'.
Types of property 'length' are incompatible.
Type '6' is not assignable to type '3'.
Source has 6 element(s) but target allows only 3.


==== tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts (4 errors) ====
Expand All @@ -21,18 +17,15 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionConte
var tup: [number, number, number] = [1, 2, 3, 4];
~~~
!!! error TS2322: Type '[number, number, number, number]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '4' is not assignable to type '3'.
!!! error TS2322: Source has 4 element(s) but target allows only 3.
var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"];
~~~~
!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[string | number, string | number, string | number]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '4' is not assignable to type '3'.
!!! error TS2322: Source has 4 element(s) but target allows only 3.
var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error
~~~~
!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '4' is not assignable to type '3'.
!!! error TS2322: Source has 4 element(s) but target allows only 3.

// In a contextually typed array literal expression containing one or more spread elements,
// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any.
Expand All @@ -41,6 +34,5 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionConte
var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error
~~~~
!!! error TS2322: Type '[number, number, number, number, number, number]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '6' is not assignable to type '3'.
!!! error TS2322: Source has 6 element(s) but target allows only 3.

18 changes: 10 additions & 8 deletions tests/baselines/reference/arrayLiterals3.errors.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2739: Type '[]' is missing the following properties from type '[any, any, any]': 0, 1, 2
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type '[]' is not assignable to type '[any, any, any]'.
Source has 0 element(s) but target requires 3.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,38): error TS2322: Type 'string' is not assignable to type 'boolean'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,48): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,51): error TS2322: Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
Types of property 'length' are incompatible.
Type '4' is not assignable to type '2'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2739: Type 'number[]' is missing the following properties from type '[number, number, number]': 0, 1, 2
Source has 4 element(s) but target allows only 2.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
Target requires 3 element(s) but source may have fewer.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
The types returned by 'pop()' are incompatible between these types.
Type 'string | number' is not assignable to type 'Number'.
Expand All @@ -24,7 +25,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error

var a0: [any, any, any] = []; // Error
~~
!!! error TS2739: Type '[]' is missing the following properties from type '[any, any, any]': 0, 1, 2
!!! error TS2322: Type '[]' is not assignable to type '[any, any, any]'.
!!! error TS2322: Source has 0 element(s) but target requires 3.
var a1: [boolean, string, number] = ["string", 1, true]; // Error
~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
Expand All @@ -40,8 +42,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
var [b1, b2]: [number, number] = [1, 2, "string", true];
~~~~~~~~
!!! error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '4' is not assignable to type '2'.
!!! error TS2322: Source has 4 element(s) but target allows only 2.

// The resulting type an array literal expression is determined as follows:
// - the resulting type is an array type with an element type that is the union of the types of the
Expand All @@ -59,7 +60,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
var c0: tup = [...temp2]; // Error
var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number]
~~
!!! error TS2739: Type 'number[]' is missing the following properties from type '[number, number, number]': 0, 1, 2
!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Target requires 3 element(s) but source may have fewer.
var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
~~
!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
Expand Down
Loading