-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
allow BindingPattern in FunctionRestParameter #26017
Changes from all commits
d4f6b9b
421a5f2
3894d05
5b122db
5f3f6cc
63c80dd
66314e1
e68f495
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. | ||
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(2,1): error TS2554: Expected 2 arguments, but got 1. | ||
|
||
|
||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (2 errors) ==== | ||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ==== | ||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { } | ||
~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2501: A rest element cannot contain a binding pattern. | ||
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]])); | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2554: Expected 2 arguments, but got 1. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. | ||
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,52): error TS2322: Type 'true' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (2 errors) ==== | ||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (1 errors) ==== | ||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } | ||
~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2501: A rest element cannot contain a binding pattern. | ||
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]])); | ||
~~~~ | ||
!!! error TS2322: Type 'true' is not assignable to type 'number'. |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
=================================================================== | ||
JsFile: restParameterWithBindingPattern1.js | ||
mapUrl: restParameterWithBindingPattern1.js.map | ||
sourceRoot: | ||
sources: restParameterWithBindingPattern1.ts | ||
=================================================================== | ||
------------------------------------------------------------------- | ||
emittedFile:tests/cases/compiler/restParameterWithBindingPattern1.js | ||
sourceFile:restParameterWithBindingPattern1.ts | ||
------------------------------------------------------------------- | ||
>>>function a() { | ||
1 > | ||
2 >^^^^^^^^^ | ||
3 > ^ | ||
4 > ^^^^^^^-> | ||
1 > | ||
2 >function | ||
3 > a | ||
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) | ||
2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) | ||
3 >Emitted(1, 11) Source(1, 11) + SourceIndex(0) | ||
--- | ||
>>> var _a = []; | ||
1->^^^^ | ||
2 > ^^^^^^^^^^^^ | ||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
1->( | ||
2 > ...{a, b} | ||
1->Emitted(2, 5) Source(1, 12) + SourceIndex(0) | ||
2 >Emitted(2, 17) Source(1, 21) + SourceIndex(0) | ||
--- | ||
>>> for (var _i = 0; _i < arguments.length; _i++) { | ||
1->^^^^^^^^^ | ||
2 > ^^^^^^^^^^ | ||
3 > ^^ | ||
4 > ^^^^^^^^^^^^^^^^^^^^^ | ||
5 > ^^ | ||
6 > ^^^^ | ||
1-> | ||
2 > ...{a, b} | ||
3 > | ||
4 > ...{a, b} | ||
5 > | ||
6 > ...{a, b} | ||
1->Emitted(3, 10) Source(1, 12) + SourceIndex(0) | ||
2 >Emitted(3, 20) Source(1, 21) + SourceIndex(0) | ||
3 >Emitted(3, 22) Source(1, 12) + SourceIndex(0) | ||
4 >Emitted(3, 43) Source(1, 21) + SourceIndex(0) | ||
5 >Emitted(3, 45) Source(1, 12) + SourceIndex(0) | ||
6 >Emitted(3, 49) Source(1, 21) + SourceIndex(0) | ||
--- | ||
>>> _a[_i] = arguments[_i]; | ||
1 >^^^^^^^^ | ||
2 > ^^^^^^^^^^^^^^^^^^^^^^^ | ||
1 > | ||
2 > ...{a, b} | ||
1 >Emitted(4, 9) Source(1, 12) + SourceIndex(0) | ||
2 >Emitted(4, 32) Source(1, 21) + SourceIndex(0) | ||
--- | ||
>>> } | ||
>>> var a = _a.a, b = _a.b; | ||
1 >^^^^ | ||
2 > ^^^^ | ||
3 > ^^^^^^^^ | ||
4 > ^^ | ||
5 > ^^^^^^^^ | ||
6 > ^ | ||
1 > | ||
2 > ...{ | ||
3 > a | ||
4 > , | ||
5 > b | ||
6 > } | ||
1 >Emitted(6, 5) Source(1, 12) + SourceIndex(0) | ||
2 >Emitted(6, 9) Source(1, 16) + SourceIndex(0) | ||
3 >Emitted(6, 17) Source(1, 17) + SourceIndex(0) | ||
4 >Emitted(6, 19) Source(1, 19) + SourceIndex(0) | ||
5 >Emitted(6, 27) Source(1, 20) + SourceIndex(0) | ||
6 >Emitted(6, 28) Source(1, 21) + SourceIndex(0) | ||
--- | ||
>>>} | ||
1 > | ||
2 >^ | ||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
1 >) { | ||
2 >} | ||
1 >Emitted(7, 1) Source(1, 25) + SourceIndex(0) | ||
2 >Emitted(7, 2) Source(1, 26) + SourceIndex(0) | ||
--- | ||
>>>//# sourceMappingURL=restParameterWithBindingPattern1.js.map |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this error still be there if its a object binding pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean something like
(...{length}) => length
? The spec allows it and there are already tests to ensure type inference and downlevel emit works as expected.