mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
68 lines
4.1 KiB
Plaintext
68 lines
4.1 KiB
Plaintext
destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2493: Tuple type '[]' of length '0' has no element at index '0'.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2493: Tuple type '[]' of length '0' has no element at index '1'.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(9,51): error TS2322: Type 'number' is not assignable to type 'boolean'.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'.
|
|
Target requires 2 element(s) but source may have fewer.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
|
|
Target requires 2 element(s) but source may have fewer.
|
|
destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2488: Type 'F' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
|
|
|
|
==== destructuringArrayBindingPatternAndAssignment2.ts (9 errors) ====
|
|
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
|
// S is the type Any, or
|
|
var [[a0], [[a1]]] = [] // Error
|
|
~~~~
|
|
!!! error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
~~~~
|
|
!!! error TS2493: Tuple type '[]' of length '0' has no element at index '0'.
|
|
~~~~~~
|
|
!!! error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
~~~~~~
|
|
!!! error TS2493: Tuple type '[]' of length '0' has no element at index '1'.
|
|
var [[a2], [[a3]]] = undefined // Error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2488: Type 'undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
|
|
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
|
// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
|
|
// where N is the numeric index of E in the array assignment pattern, or
|
|
var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
|
|
interface J extends Array<Number> {
|
|
2: number;
|
|
}
|
|
|
|
function bar(): J {
|
|
return <[number, number, number]>[1, 2, 3];
|
|
}
|
|
var [b3 = "string", b4, b5] = bar(); // Error
|
|
|
|
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
|
|
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
|
|
var temp = [1, 2, 3]
|
|
var [c0, c1]: [number, number] = [...temp]; // Error
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number[]' is not assignable to type '[number, number]'.
|
|
!!! error TS2322: Target requires 2 element(s) but source may have fewer.
|
|
var [c2, c3]: [string, string] = [...temp]; // Error
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
|
|
!!! error TS2322: Target requires 2 element(s) but source may have fewer.
|
|
|
|
interface F {
|
|
[idx: number]: boolean
|
|
}
|
|
|
|
function foo(idx: number): F {
|
|
return {
|
|
2: true
|
|
}
|
|
}
|
|
var [c4, c5, c6] = foo(1); // Error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2488: Type 'F' must have a '[Symbol.iterator]()' method that returns an iterator. |