Skip to content

Destructuring #1346

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

Merged
merged 38 commits into from
Dec 9, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
86f290f
Initial parser support for destructuring patterns
ahejlsberg Nov 5, 2014
a01b440
Rework tracking and error reporting related to widening of types
ahejlsberg Nov 6, 2014
2d3752e
Merge branch 'master' into destructuring
ahejlsberg Nov 6, 2014
3d3212b
Adding binding patterns to declaration names
ahejlsberg Nov 7, 2014
af00c71
End-to-end support for destructuring in variable declarations
ahejlsberg Nov 10, 2014
3cda261
Rudimentary support in language service
ahejlsberg Nov 11, 2014
bd65f16
Parser errors for destructuring declarations
ahejlsberg Nov 11, 2014
a6401bb
Adding destructuring variable declaration error messages
ahejlsberg Nov 12, 2014
7840f0d
Moving error reporting to getWidenedTypeForVariableDeclaration
ahejlsberg Nov 12, 2014
850f3cb
Destructuring parameter declarations
ahejlsberg Nov 19, 2014
2ed5f41
Destructuring of tuple type cannot specify extra variables
ahejlsberg Nov 20, 2014
58c3c2f
Merge branch 'master' into destructuring
ahejlsberg Nov 20, 2014
d39749f
Adding SyntaxKind.FunctionType/ConstructorType to isAnyFunction
ahejlsberg Nov 20, 2014
607140b
Support for destructuring assignments
ahejlsberg Nov 21, 2014
38a2640
Propagate node kind in variable/parameter destructuring declarations
ahejlsberg Nov 22, 2014
6b96386
Allow string or numeric literal as property name of object binding
ahejlsberg Nov 22, 2014
8ed1f24
Fine tuning array and tuple type checks in destructuring
ahejlsberg Nov 23, 2014
d8ecd8c
Fixed bug in union type identity comparison
ahejlsberg Nov 24, 2014
98eaca5
Accepting new baselines
ahejlsberg Nov 28, 2014
cf3e3ac
Rewriting and emit for destructuring declarations
ahejlsberg Nov 28, 2014
28a73bc
Emit of rest parameter for loop uses unique temporary variable name
ahejlsberg Nov 29, 2014
ec7ce72
Removing unused diagnostics related to '_i' variable name
ahejlsberg Nov 29, 2014
501a370
Accepting new baselines
ahejlsberg Nov 29, 2014
3ff2a62
Allow assignment expressions as destructuring assignment target
ahejlsberg Nov 30, 2014
9e63911
Emit for destructuring assignments
ahejlsberg Dec 2, 2014
ab35da9
Baseline changes from updating rest parameter emit to use new tempora…
ahejlsberg Dec 2, 2014
7994e90
Emit for destructuring parameter declarations
ahejlsberg Dec 2, 2014
0731a28
Support exported destructuring variable declarations
ahejlsberg Dec 2, 2014
dc39de1
Removing fourslash test that no longer applies
ahejlsberg Dec 2, 2014
ecfcb9d
Fixing fourslash test
ahejlsberg Dec 3, 2014
65d1510
Adding rudimentary tests
ahejlsberg Dec 3, 2014
816abb1
Merge branch 'master' into destructuring
ahejlsberg Dec 4, 2014
b49e277
Addressing CR feedback
ahejlsberg Dec 5, 2014
4118ffc
Accepting new baselines
ahejlsberg Dec 5, 2014
05c9966
Addressing CR feedback:
ahejlsberg Dec 6, 2014
b3dffff
Addressing a bit more CR feedback
ahejlsberg Dec 6, 2014
459dee0
Merge branch 'master' into destructuring
ahejlsberg Dec 8, 2014
7bc35b3
Merge branch 'master' into destructuring
ahejlsberg Dec 9, 2014
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 Nov 28, 2014
commit 98eaca541a25a05eb0b38adab5195b01295585dd
9 changes: 6 additions & 3 deletions tests/baselines/reference/assignmentLHSIsValue.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,30): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,13): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,21): error TS2364: Invalid left-hand side of assignment expression.
Expand All @@ -40,7 +41,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.


==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (40 errors) ====
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (41 errors) ====
// expected error for all the LHS of assignments
var value;

Expand Down Expand Up @@ -111,7 +112,9 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7

// array literals
['', ''] = value;
~~~~~~~~
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~~
!!! error TS2364: Invalid left-hand side of assignment expression.

// super
Expand Down
6 changes: 5 additions & 1 deletion tests/baselines/reference/classExpression.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ tests/cases/conformance/classes/classExpression.ts(1,9): error TS1109: Expressio
tests/cases/conformance/classes/classExpression.ts(5,10): error TS1109: Expression expected.
tests/cases/conformance/classes/classExpression.ts(5,16): error TS1005: ':' expected.
tests/cases/conformance/classes/classExpression.ts(5,19): error TS1005: ',' expected.
tests/cases/conformance/classes/classExpression.ts(5,19): error TS1165: A destructuring declaration must have an initializer.
tests/cases/conformance/classes/classExpression.ts(7,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/classes/classExpression.ts(10,13): error TS1109: Expression expected.
tests/cases/conformance/classes/classExpression.ts(5,16): error TS2304: Cannot find name 'C2'.


==== tests/cases/conformance/classes/classExpression.ts (7 errors) ====
==== tests/cases/conformance/classes/classExpression.ts (8 errors) ====
var x = class C {
~~~~~
!!! error TS1109: Expression expected.
Expand All @@ -21,9 +22,12 @@ tests/cases/conformance/classes/classExpression.ts(5,16): error TS2304: Cannot f
!!! error TS1005: ':' expected.
~
!!! error TS1005: ',' expected.
~
~~
!!! error TS2304: Cannot find name 'C2'.
}
~~~~~
!!! error TS1165: A destructuring declaration must have an initializer.
}
~
!!! error TS1128: Declaration or statement expected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>Derived2 : typeof Derived2

var r2 = f({ x: new Base(), y: new Derived2() }); // {}[]
>r2 : Base[]
>r2 : (Base | Derived2)[]
>f({ x: new Base(), y: new Derived2() }) : (Base | Derived2)[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (T | U)[]
>{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; }
Expand Down
6 changes: 5 additions & 1 deletion tests/baselines/reference/nestedClassDeclaration.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ tests/cases/conformance/classes/nestedClassDeclaration.ts(10,5): error TS1129: S
tests/cases/conformance/classes/nestedClassDeclaration.ts(12,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/classes/nestedClassDeclaration.ts(15,11): error TS1005: ':' expected.
tests/cases/conformance/classes/nestedClassDeclaration.ts(15,14): error TS1005: ',' expected.
tests/cases/conformance/classes/nestedClassDeclaration.ts(15,14): error TS1165: A destructuring declaration must have an initializer.
tests/cases/conformance/classes/nestedClassDeclaration.ts(17,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/classes/nestedClassDeclaration.ts(15,11): error TS2304: Cannot find name 'C4'.


==== tests/cases/conformance/classes/nestedClassDeclaration.ts (8 errors) ====
==== tests/cases/conformance/classes/nestedClassDeclaration.ts (9 errors) ====
// nested classes are not allowed

class C {
Expand Down Expand Up @@ -36,9 +37,12 @@ tests/cases/conformance/classes/nestedClassDeclaration.ts(15,11): error TS2304:
!!! error TS1005: ':' expected.
~
!!! error TS1005: ',' expected.
~
~~
!!! error TS2304: Cannot find name 'C4'.
}
~~~~~
!!! error TS1165: A destructuring declaration must have an initializer.
}
~
!!! error TS1128: Declaration or statement expected.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(12,6): error TS1112: A class member cannot be declared optional.
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(20,6): error TS1112: A class member cannot be declared optional.
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1160: An object member cannot be declared optional.
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1162: An object member cannot be declared optional.


==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts (3 errors) ====
Expand Down Expand Up @@ -33,5 +33,5 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith
var b = {
x?: 1 // error

!!! error TS1160: An object member cannot be declared optional.
!!! error TS1162: An object member cannot be declared optional.
}
30 changes: 9 additions & 21 deletions tests/baselines/reference/parserCommaInTypeMemberList2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,38): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,60): error TS1005: ';' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,70): error TS1128: Declaration or statement expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,38): error TS1165: A destructuring declaration must have an initializer.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,70): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,71): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,9): error TS2304: Cannot find name '$'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,31): error TS2304: Cannot find name 'any'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,50): error TS2304: Cannot find name 'any'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,55): error TS2304: Cannot find name 'width'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts(1,62): error TS2304: Cannot find name 'string'.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts (8 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserCommaInTypeMemberList2.ts (4 errors) ====
var s = $.extend< { workItem: any }, { workItem: any, width: string }>({ workItem: this._workItem }, {});
~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1005: ';' expected.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1165: A destructuring declaration must have an initializer.
~
!!! error TS1128: Declaration or statement expected.
!!! error TS1005: ',' expected.
~
!!! error TS1134: Variable declaration expected.
~
!!! error TS2304: Cannot find name '$'.
~~~
!!! error TS2304: Cannot find name 'any'.
~~~
!!! error TS2304: Cannot find name 'any'.
~~~~~
!!! error TS2304: Cannot find name 'width'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts(1,14): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts(1,14): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts(2,2): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts (3 errors) ====
function f(a {
~
!!! error TS1005: ')' expected.
}
!!! error TS1005: ',' expected.
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}

!!! error TS1005: ')' expected.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList2.ts(1,13): error TS1009: Trailing comma not allowed.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList2.ts(1,15): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList2.ts(2,2): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList2.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList2.ts (2 errors) ====
function f(a, {
~
!!! error TS1009: Trailing comma not allowed.
~
!!! error TS1005: ')' expected.
}
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
!!! error TS1005: ')' expected.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts(1,11): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts(1,14): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts(1,17): error TS1005: ')' expected.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts (2 errors) ====
(a:number => { }
~~
!!! error TS1005: ',' expected.
~
!!! error TS1005: ')' expected.
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS1005: '=' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,20): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,20): error TS1165: A destructuring declaration must have an initializer.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2304: Cannot find name 'TypeModule1'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS2304: Cannot find name 'TypeModule2'.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (4 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (5 errors) ====
var x: TypeModule1.
~~~~~~~~~~~~
module TypeModule2 {
~~~~~~~~~~~
!!! error TS1005: '=' expected.
~
!!! error TS1005: ',' expected.
~
~~~~~~
!!! error TS2304: Cannot find name 'TypeModule1'.
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'TypeModule2'.
}
~
!!! error TS1165: A destructuring declaration must have an initializer.