(node)
| 46547 | // check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in |
| 46548 | // [Yield] or [Await] contexts, respectively. |
| 46549 | function checkContextualIdentifier(node) { |
| 46550 | // Report error only if there are no parse errors in file |
| 46551 | if (!file.parseDiagnostics.length && |
| 46552 | !(node.flags & 16777216 /* NodeFlags.Ambient */) && |
| 46553 | !(node.flags & 8388608 /* NodeFlags.JSDoc */) && |
| 46554 | !ts.isIdentifierName(node)) { |
| 46555 | // strict mode identifiers |
| 46556 | if (inStrictMode && |
| 46557 | node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && |
| 46558 | node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { |
| 46559 | file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); |
| 46560 | } |
| 46561 | else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { |
| 46562 | if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { |
| 46563 | file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); |
| 46564 | } |
| 46565 | else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { |
| 46566 | file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); |
| 46567 | } |
| 46568 | } |
| 46569 | else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { |
| 46570 | file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); |
| 46571 | } |
| 46572 | } |
| 46573 | } |
| 46574 | function getStrictModeIdentifierMessage(node) { |
| 46575 | // Provide specialized messages to help the user understand why we think they're in |
| 46576 | // strict mode. |
no test coverage detected