-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix 8262: allow unparenthesized parameter in async arrow-function #8444
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
135bf66
Allow unparenthesize of parameter in async arrow-function
be4c791
Add tests and baselines
cbf021e
Address PR
5469772
Address PR: refactor to use "parseSimpleArrowFunctionExpression"
3262ff8
Address PR: add comment
91e5d53
Address PR
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| //// [asyncUnParenthesizedArrowFunction_es6.ts] | ||
|
|
||
| declare function someOtherFunction(i: any): Promise<void>; | ||
| const x = async i => await someOtherFunction(i) | ||
| const x1 = async (i) => await someOtherFunction(i); | ||
|
|
||
| //// [asyncUnParenthesizedArrowFunction_es6.js] | ||
| const x = (i) => __awaiter(this, void 0, void 0, function* () { return yield someOtherFunction(i); }); | ||
| const x1 = (i) => __awaiter(this, void 0, void 0, function* () { return yield someOtherFunction(i); }); |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| === tests/cases/conformance/async/es6/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es6.ts === | ||
|
|
||
| declare function someOtherFunction(i: any): Promise<void>; | ||
| >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0)) | ||
| >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 1, 35)) | ||
| >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) | ||
|
|
||
| const x = async i => await someOtherFunction(i) | ||
| >x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 5)) | ||
| >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 15)) | ||
| >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0)) | ||
| >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 15)) | ||
|
|
||
| const x1 = async (i) => await someOtherFunction(i); | ||
| >x1 : Symbol(x1, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 5)) | ||
| >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 18)) | ||
| >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0)) | ||
| >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 3, 18)) | ||
|
|
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| === tests/cases/conformance/async/es6/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es6.ts === | ||
|
|
||
| declare function someOtherFunction(i: any): Promise<void>; | ||
| >someOtherFunction : (i: any) => Promise<void> | ||
| >i : any | ||
| >Promise : Promise<T> | ||
|
|
||
| const x = async i => await someOtherFunction(i) | ||
| >x : (i: any) => Promise<void> | ||
| >async i => await someOtherFunction(i) : (i: any) => Promise<void> | ||
| >i : any | ||
| >await someOtherFunction(i) : void | ||
| >someOtherFunction(i) : Promise<void> | ||
| >someOtherFunction : (i: any) => Promise<void> | ||
| >i : any | ||
|
|
||
| const x1 = async (i) => await someOtherFunction(i); | ||
| >x1 : (i: any) => Promise<void> | ||
| >async (i) => await someOtherFunction(i) : (i: any) => Promise<void> | ||
| >i : any | ||
| >await someOtherFunction(i) : void | ||
| >someOtherFunction(i) : Promise<void> | ||
| >someOtherFunction : (i: any) => Promise<void> | ||
| >i : any | ||
|
|
6 changes: 6 additions & 0 deletions
6
...s/cases/conformance/async/es6/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es6.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // @target: ES6 | ||
| // @noEmitHelpers: true | ||
|
|
||
| declare function someOtherFunction(i: any): Promise<void>; | ||
| const x = async i => await someOtherFunction(i) | ||
| const x1 = async (i) => await someOtherFunction(i); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can you check first that
token === SyntaxKind.AsyncKeywordbefore calling the function?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.
Sure. I just realize I should do that since
lookAheadcan be expensive