62 lines
No EOL
4.8 KiB
Text
62 lines
No EOL
4.8 KiB
Text
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,5): error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'.
|
|
Types of property 'a1' are incompatible.
|
|
Type 'boolean' is not assignable to type 'number'.
|
|
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'.
|
|
Types of property '1' are incompatible.
|
|
Type '[[boolean]]' is not assignable to type '[[string]]'.
|
|
Types of property '0' are incompatible.
|
|
Type '[boolean]' is not assignable to type '[string]'.
|
|
Types of property '0' are incompatible.
|
|
Type 'boolean' is not assignable to type 'string'.
|
|
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'.
|
|
Types of property 't2' are incompatible.
|
|
Type 'string' is not assignable to type 'number'.
|
|
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,16): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature.
|
|
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,24): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature.
|
|
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(19,10): error TS2322: Type 'string[]' is not assignable to type 'number[]'.
|
|
Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (6 errors) ====
|
|
// The type T associated with a destructuring variable declaration is determined as follows:
|
|
// If the declaration includes a type annotation, T is that type.
|
|
var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error
|
|
~~~~~~~~
|
|
!!! error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'.
|
|
!!! error TS2322: Types of property 'a1' are incompatible.
|
|
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
|
|
var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'.
|
|
!!! error TS2322: Types of property '1' are incompatible.
|
|
!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'.
|
|
!!! error TS2322: Types of property '0' are incompatible.
|
|
!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'.
|
|
!!! error TS2322: Types of property '0' are incompatible.
|
|
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|
|
|
|
// The type T associated with a destructuring variable declaration is determined as follows:
|
|
// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression.
|
|
var temp = { t1: true, t2: "false" };
|
|
var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error
|
|
~~
|
|
!!! error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'.
|
|
!!! error TS2322: Types of property 't2' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
|
|
// The type T associated with a binding element is determined as follows:
|
|
// If the binding element is a rest element, T is an array type with
|
|
// an element type E, where E is the type of the numeric index signature of S.
|
|
var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error
|
|
~~
|
|
!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature.
|
|
~~
|
|
!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature.
|
|
|
|
// When a destructuring variable declaration, binding property, or binding element specifies
|
|
// an initializer expression, the type of the initializer expression is required to be assignable
|
|
// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element.
|
|
var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error
|
|
~~
|
|
!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'. |