Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Accepting new baselines
  • Loading branch information
ahejlsberg committed Sep 10, 2015
commit 273b9ff1ec12f4a81c8cc96296b3fef0aec6eac2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value


==== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts (3 errors) ====
var [x10, [y10, [z10]]] = [1, ["hello", [true]]];

var [x11 = 0, y11 = ""] = [1, "hello"];
var [a11, b11, c11] = [];
~~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value

var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]];

var [x13, y13] = [1, "hello"];
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];

This file was deleted.

This file was deleted.

28 changes: 23 additions & 5 deletions tests/baselines/reference/declarationsAndAssignments.errors.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2459: Type '{}' has no property 'a' and no string index signature.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2459: Type '{}' has no property 'b' and no string index signature.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature.
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'.
Expand All @@ -21,12 +27,14 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6):
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (16 errors) ====
==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (22 errors) ====
function f0() {
var [] = [1, "hello"];
var [x] = [1, "hello"];
var [x, y] = [1, "hello"];
var [x, y, z] = [1, "hello"];
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
var [,, x] = [0, 1, 2];
var x: number;
var y: string;
Expand Down Expand Up @@ -98,7 +106,17 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):

function f8() {
var [a, b, c] = []; // Ok, [] is an array
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
var [d, e, f] = [1]; // Error, [1] is a tuple
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
}

function f9() {
Expand All @@ -114,9 +132,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
function f10() {
var { a, b } = {}; // Error
~
!!! error TS2459: Type '{}' has no property 'a' and no string index signature.
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~
!!! error TS2459: Type '{}' has no property 'b' and no string index signature.
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
var { a, b } = []; // Error
~
!!! error TS2459: Type 'undefined[]' has no property 'a' and no string index signature.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value


==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts (3 errors) ====
/* AssignmentPattern:
* ObjectAssignmentPattern
* ArrayAssignmentPattern
* ArrayAssignmentPattern:
* [Elision<opt> AssignmentRestElementopt ]
* [AssignmentElementList]
* [AssignmentElementList, Elision<opt> AssignmentRestElementopt ]
* AssignmentElementList:
* Elision<opt> AssignmentElement
* AssignmentElementList, Elisionopt AssignmentElement
* AssignmentElement:
* LeftHandSideExpression Initialiseropt
* AssignmentPattern Initialiseropt
* AssignmentRestElement:
* ... LeftHandSideExpression
*/

// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
// An expression of type S is considered assignable to an assignment target V if one of the following is true

// 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]: any = undefined;
var [a2 = false, a3 = 1]: any = undefined;

// 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] = [2, 3, 4];
var [b3, b4, b5]: [number, number, string] = [1, 2, "string"];

function foo() {
return [1, 2, 3];
}

var [b6, b7] = foo();
var [...b8] = foo();

// 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] = [...temp];
var [c2] = [];
~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]]
~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value
var [[c5], c6]: [[string|number], boolean] = [[1], true];
var [, c7] = [1, 2, 3];
var [,,, c8] = [1, 2, 3, 4];
var [,,, c9] = [1, 2, 3, 4];
var [,,,...c10] = [1, 2, 3, 4, "hello"];
var [c11, c12, ...c13] = [1, 2, "string"];
var [c14, c15, c16] = [1, 2, "string"];


Loading