71 lines
4.2 KiB
Plaintext
71 lines
4.2 KiB
Plaintext
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'.
|
|
Types of property '1' are incompatible.
|
|
Type 'number' is not assignable to type 'boolean'.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'.
|
|
Property 'toFixed' is missing in type 'String'.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'.
|
|
Property '0' is missing in type 'number[]'.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
|
|
Property '0' is missing in type 'number[]'.
|
|
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type.
|
|
|
|
|
|
==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 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 TS2461: Type 'undefined' is not an array type.
|
|
~~~~~~
|
|
!!! error TS2461: Type 'undefined' is not an array type.
|
|
var [[a2], [[a3]]] = undefined // Error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2461: Type 'undefined' is not an array type.
|
|
|
|
// 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, number, string]' is not assignable to type '[number, boolean, string]'.
|
|
!!! error TS2322: Types of property '1' are incompatible.
|
|
!!! 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
|
|
~~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
|
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
|
|
|
|
// 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: Property '0' is missing in type 'number[]'.
|
|
var [c2, c3]: [string, string] = [...temp]; // Error
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
|
|
!!! error TS2322: Property '0' is missing in type 'number[]'.
|
|
|
|
interface F {
|
|
[idx: number]: boolean
|
|
}
|
|
|
|
function foo(idx: number): F {
|
|
return {
|
|
2: true
|
|
}
|
|
}
|
|
var [c4, c5, c6] = foo(1); // Error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2461: Type 'F' is not an array type. |