Skip to content

Commit

Permalink
fix(typescript-estree): parsing error for await in non-async function
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Sep 18, 2019
1 parent c3c8b86 commit 9ef4e76
Show file tree
Hide file tree
Showing 4 changed files with 618 additions and 0 deletions.
@@ -0,0 +1,4 @@
function foo() {
const bar = await baz();
return bar.qux;
}
1 change: 1 addition & 0 deletions packages/typescript-estree/src/semantic-errors.ts
Expand Up @@ -86,6 +86,7 @@ function whitelistSupportedDiagnostics(
case 1242: // ts 3.2 "'abstract' modifier can only appear on a class, method, or property declaration."
case 1246: // ts 3.2 "An interface property cannot have an initializer."
case 1255: // ts 3.2 "A definite assignment assertion '!' is not permitted in this context."
case 1308: // ts 3.2 "'await' expression is only allowed within an async function. Did you mean to mark this function as 'async'?"
case 2364: // ts 3.2 "The left-hand side of an assignment expression must be a variable or a property access."
case 2369: // ts 3.2 "A parameter property is only allowed in a constructor implementation."
case 2462: // ts 3.2 "A rest element must be last in a destructuring pattern."
Expand Down
Expand Up @@ -1669,6 +1669,15 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/async-function-with-var-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/await-without-async-function.src 1`] = `
Object {
"column": 14,
"index": 31,
"lineNumber": 2,
"message": "'await' expression is only allowed within an async function.",
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/call-signatures.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/call-signatures-with-generics.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down

0 comments on commit 9ef4e76

Please sign in to comment.