Reparse top level 'await' in modules (#39084)

* Reparse top-level 'await' in modules

* Add more tests and additional diagnostics

* One more incremental parse test
This commit is contained in:
Ron Buckton authored and GitHub committed 2020-06-18 23:43:18 -07:00
1 parent 59ad375234
commit fe33e61823
111 files changed
+3234 -187

No files matched your search

+33 -10
View File
@@ -28255,7 +28255,7 @@ namespace ts {
return undefinedWideningType;
}
function isTopLevelAwait(node: AwaitExpression) {
function isInTopLevelContext(node: Node) {
const container = getThisContainer(node, /*includeArrowFunctions*/ true);
return isSourceFile(container);
}
@@ -28264,7 +28264,7 @@ namespace ts {
// Grammar checking
if (produceDiagnostics) {
if (!(node.flags & NodeFlags.AwaitContext)) {
if (isTopLevelAwait(node)) {
if (isInTopLevelContext(node)) {
const sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
let span: TextSpan | undefined;
@@ -33586,7 +33586,7 @@ namespace ts {
function checkThrowStatement(node: ThrowStatement) {
// Grammar checking
if (!checkGrammarStatementInAmbientContext(node)) {
if (node.expression === undefined) {
if (isIdentifier(node.expression) && !node.expression.escapedText) {
grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here);
}
}
@@ -34861,6 +34861,7 @@ namespace ts {
}
function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) {
checkGrammarAwaitIdentifier(node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name!);
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name!);
checkAliasSymbol(node);
@@ -37626,17 +37627,32 @@ namespace ts {
return false;
}
function checkGrammarAwaitIdentifier(name: Identifier | undefined): boolean {
if (name && isIdentifier(name) && name.originalKeywordKind === SyntaxKind.AwaitKeyword && isInTopLevelContext(name.parent)) {
const file = getSourceFileOfNode(name);
if (!file.isDeclarationFile && isExternalModule(file)) {
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, idText(name));
}
}
return false;
}
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration | MethodSignature): boolean {
// Prevent cascading error by short-circuit
const file = getSourceFileOfNode(node);
return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) ||
return checkGrammarDecoratorsAndModifiers(node) ||
checkGrammarTypeParameterList(node.typeParameters, file) ||
(isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
checkGrammarParameterList(node.parameters) ||
checkGrammarArrowFunction(node, file) ||
(isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
}
function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean {
const file = getSourceFileOfNode(node);
return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
return (isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
checkGrammarClassDeclarationHeritageClauses(node) ||
checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node: Node, file: SourceFile): boolean {
@@ -38276,11 +38292,15 @@ namespace ts {
if (node.propertyName) {
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_have_a_property_name);
}
}
if (node.initializer) {
// Error on equals token which immediately precedes the initializer
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
}
if (isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
return true;
}
if (node.dotDotDotToken && node.initializer) {
// Error on equals token which immediately precedes the initializer
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
}
}
@@ -38341,6 +38361,9 @@ namespace ts {
}
}
}
if (isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
return true;
}
if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || node.flags & NodeFlags.Ambient)) {
return grammarErrorOnNode(node.exclamationToken, Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
+5
View File
@@ -867,6 +867,11 @@
"category": "Error",
"code": 1261
},
"Identifier expected. '{0}' is a reserved word at the top-level of a module.": {
"category": "Error",
"code": 1262
},
"'with' statements are not allowed in an async function block.": {
"category": "Error",
"code": 1300
+61 -10
View File
@@ -558,8 +558,29 @@ namespace ts {
decorators,
modifiers
);
node.name = asName(name);
node.transformFlags |= propagateChildFlags(node.name);
name = asName(name);
node.name = name;
// The PropertyName of a member is allowed to be `await`.
// We don't need to exclude `await` for type signatures since types
// don't propagate child flags.
if (name) {
switch (node.kind) {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertyAssignment:
if (isIdentifier(name)) {
node.transformFlags |= propagateIdentifierNameFlags(name);
break;
}
// fall through
default:
node.transformFlags |= propagateChildFlags(name);
break;
}
}
return node;
}
@@ -633,7 +654,7 @@ namespace ts {
type
);
node.body = body;
node.transformFlags |= propagateChildFlags(node.body);
node.transformFlags |= propagateChildFlags(node.body) & ~TransformFlags.ContainsPossibleTopLevelAwait;
if (!body) node.transformFlags |= TransformFlags.ContainsTypeScript;
return node;
}
@@ -826,6 +847,9 @@ namespace ts {
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
node.typeArguments = createNodeArray(typeArguments);
}
if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
node.transformFlags |= TransformFlags.ContainsPossibleTopLevelAwait;
}
return node;
}
@@ -1015,7 +1039,7 @@ namespace ts {
node.right = asName(right);
node.transformFlags |=
propagateChildFlags(node.left) |
propagateChildFlags(node.right);
propagateIdentifierNameFlags(node.right);
return node;
}
@@ -2030,9 +2054,13 @@ namespace ts {
node.propertyName = asName(propertyName);
node.dotDotDotToken = dotDotDotToken;
node.transformFlags |=
propagateChildFlags(node.propertyName) |
propagateChildFlags(node.dotDotDotToken) |
TransformFlags.ContainsES2015;
if (node.propertyName) {
node.transformFlags |= isIdentifier(node.propertyName) ?
propagateIdentifierNameFlags(node.propertyName) :
propagateChildFlags(node.propertyName);
}
if (dotDotDotToken) node.transformFlags |= TransformFlags.ContainsRestOrSpread;
return node;
}
@@ -2096,7 +2124,9 @@ namespace ts {
node.name = asName(name);
node.transformFlags =
propagateChildFlags(node.expression) |
propagateChildFlags(node.name);
(isIdentifier(node.name) ?
propagateIdentifierNameFlags(node.name) :
propagateChildFlags(node.name));
if (isSuperKeyword(expression)) {
// super method calls require a lexical 'this'
// super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -2126,10 +2156,12 @@ namespace ts {
node.questionDotToken = questionDotToken;
node.name = asName(name);
node.transformFlags |=
TransformFlags.ContainsES2020 |
propagateChildFlags(node.expression) |
propagateChildFlags(node.questionDotToken) |
propagateChildFlags(node.name) |
TransformFlags.ContainsES2020;
(isIdentifier(node.name) ?
propagateIdentifierNameFlags(node.name) :
propagateChildFlags(node.name));
return node;
}
@@ -3558,6 +3590,7 @@ namespace ts {
node.transformFlags |=
propagateChildrenFlags(node.members) |
TransformFlags.ContainsTypeScript;
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Enum declarations cannot contain `await`
return node;
}
@@ -3601,6 +3634,7 @@ namespace ts {
propagateChildFlags(node.body) |
TransformFlags.ContainsTypeScript;
}
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Module declarations cannot contain `await`.
return node;
}
@@ -3685,6 +3719,7 @@ namespace ts {
node.moduleReference = moduleReference;
node.transformFlags |= propagateChildFlags(node.moduleReference);
if (!isExternalModuleReference(node.moduleReference)) node.transformFlags |= TransformFlags.ContainsTypeScript;
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Import= declaration is always parsed in an Await context
return node;
}
@@ -3721,6 +3756,7 @@ namespace ts {
node.transformFlags |=
propagateChildFlags(node.importClause) |
propagateChildFlags(node.moduleSpecifier);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3752,6 +3788,7 @@ namespace ts {
if (isTypeOnly) {
node.transformFlags |= TransformFlags.ContainsTypeScript;
}
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3769,6 +3806,7 @@ namespace ts {
const node = createBaseNode<NamespaceImport>(SyntaxKind.NamespaceImport);
node.name = name;
node.transformFlags |= propagateChildFlags(node.name);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3786,6 +3824,7 @@ namespace ts {
node.transformFlags |=
propagateChildFlags(node.name) |
TransformFlags.ContainsESNext;
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3801,6 +3840,7 @@ namespace ts {
const node = createBaseNode<NamedImports>(SyntaxKind.NamedImports);
node.elements = createNodeArray(elements);
node.transformFlags |= propagateChildrenFlags(node.elements);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3819,6 +3859,7 @@ namespace ts {
node.transformFlags |=
propagateChildFlags(node.propertyName) |
propagateChildFlags(node.name);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3847,6 +3888,7 @@ namespace ts {
? parenthesizerRules().parenthesizeRightSideOfBinary(SyntaxKind.EqualsToken, /*leftSide*/ undefined, expression)
: parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
node.transformFlags |= propagateChildFlags(node.expression);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3883,6 +3925,7 @@ namespace ts {
node.transformFlags |=
propagateChildFlags(node.exportClause) |
propagateChildFlags(node.moduleSpecifier);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3909,6 +3952,7 @@ namespace ts {
const node = createBaseNode<NamedExports>(SyntaxKind.NamedExports);
node.elements = createNodeArray(elements);
node.transformFlags |= propagateChildrenFlags(node.elements);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3927,6 +3971,7 @@ namespace ts {
node.transformFlags |=
propagateChildFlags(node.propertyName) |
propagateChildFlags(node.name);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -3957,6 +4002,7 @@ namespace ts {
const node = createBaseNode<ExternalModuleReference>(SyntaxKind.ExternalModuleReference);
node.expression = expression;
node.transformFlags |= propagateChildFlags(node.expression);
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
@@ -5781,14 +5827,19 @@ namespace ts {
return tokenValue;
}
function propagatePropertyNameFlags(node: PropertyName, transformFlags: TransformFlags) {
function propagateIdentifierNameFlags(node: Identifier) {
// An IdentifierName is allowed to be `await`
return propagateChildFlags(node) & ~TransformFlags.ContainsPossibleTopLevelAwait;
}
function propagatePropertyNameFlagsOfChild(node: PropertyName, transformFlags: TransformFlags) {
return transformFlags | (node.transformFlags & TransformFlags.PropertyNamePropagatingFlags);
}
function propagateChildFlags(child: Node | undefined): TransformFlags {
if (!child) return TransformFlags.None;
const childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind);
return isNamedDeclaration(child) && isPropertyName(child.name) ? propagatePropertyNameFlags(child.name, childFlags) : childFlags;
return isNamedDeclaration(child) && isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags;
}
function propagateChildrenFlags(children: NodeArray<Node> | undefined): TransformFlags {
+5
View File
@@ -815,6 +815,11 @@ namespace ts {
|| kind === SyntaxKind.ExportDeclaration;
}
/* @internal */
export function isExportModifier(node: Modifier): node is ExportKeyword {
return node.kind === SyntaxKind.ExportKeyword;
}
/* @internal */
export function isAsyncModifier(node: Modifier): node is AsyncKeyword {
return node.kind === SyntaxKind.AsyncKeyword;
+204 -20
View File
@@ -8,6 +8,12 @@ namespace ts {
JSDoc = 1 << 5,
}
const enum SpeculationKind {
TryParse,
Lookahead,
Reparse
}
let NodeConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
let TokenConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
let IdentifierConstructor: new (kind: SyntaxKind, pos?: number, end?: number) => Node;
@@ -704,6 +710,33 @@ namespace ts {
const factory = createNodeFactory(NodeFactoryFlags.NoParenthesizerRules | NodeFactoryFlags.NoNodeConverters | NodeFactoryFlags.NoOriginalNode, baseNodeFactory);
const reparseContext: TransformationContext = {
get factory() { return factory; },
enableEmitNotification: notImplemented,
enableSubstitution: notImplemented,
endLexicalEnvironment: returnUndefined,
getCompilerOptions: notImplemented,
getEmitHost: notImplemented,
getEmitResolver: notImplemented,
getEmitHelperFactory: notImplemented,
setLexicalEnvironmentFlags: noop,
getLexicalEnvironmentFlags: () => 0,
hoistFunctionDeclaration: notImplemented,
hoistVariableDeclaration: notImplemented,
addInitializationStatement: notImplemented,
isEmitNotificationEnabled: notImplemented,
isSubstitutionEnabled: notImplemented,
onEmitNode: notImplemented,
onSubstituteNode: notImplemented,
readEmitHelpers: notImplemented,
requestEmitHelper: notImplemented,
resumeLexicalEnvironment: noop,
startLexicalEnvironment: noop,
suspendLexicalEnvironment: noop,
addDiagnostic: notImplemented,
};
let fileName: string;
let sourceFlags: NodeFlags;
let sourceText: string;
@@ -988,8 +1021,6 @@ namespace ts {
processCommentPragmas(sourceFile as {} as PragmaContext, sourceText);
processPragmasIntoFields(sourceFile as {} as PragmaContext, reportPragmaDiagnostic);
setExternalModuleIndicator(sourceFile);
sourceFile.commentDirectives = scanner.getCommentDirectives();
sourceFile.nodeCount = nodeCount;
sourceFile.identifierCount = identifierCount;
@@ -1026,6 +1057,133 @@ namespace ts {
return node;
}
function reparseTopLevelAwait(sourceFile: SourceFile) {
return visitEachChild(sourceFile, visitor, reparseContext);
function visitor(node: Node): VisitResult<Node> {
if (!(node.transformFlags & TransformFlags.ContainsPossibleTopLevelAwait)) {
return node;
}
// We explicitly visit each non-Expression node that has an immediate Expression child so that
// we can reparse the Expression in an Await context
switch (node.kind) {
case SyntaxKind.Decorator: return reparseDecorator(node as Decorator);
case SyntaxKind.ComputedPropertyName: return reparseComputedPropertyName(node as ComputedPropertyName);
case SyntaxKind.ExpressionWithTypeArguments: return reparseExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
case SyntaxKind.ExpressionStatement: return reparseExpressionStatement(node as ExpressionStatement);
case SyntaxKind.IfStatement: return reparseIfStatement(node as IfStatement);
case SyntaxKind.SwitchStatement: return reparseSwitchStatement(node as SwitchStatement);
case SyntaxKind.WithStatement: return reparseWithStatement(node as WithStatement);
case SyntaxKind.DoStatement: return reparseDoStatement(node as DoStatement);
case SyntaxKind.WhileStatement: return reparseWhileStatement(node as WhileStatement);
case SyntaxKind.ForStatement: return reparseForStatement(node as ForStatement);
case SyntaxKind.ForInStatement: return reparseForInStatement(node as ForInStatement);
case SyntaxKind.ForOfStatement: return reparseForOfStatement(node as ForOfStatement);
case SyntaxKind.ReturnStatement: return reparseReturnStatement(node as ReturnStatement);
case SyntaxKind.ThrowStatement: return reparseThrowStatement(node as ThrowStatement);
case SyntaxKind.ExportAssignment: return reparseExportAssignment(node as ExportAssignment);
case SyntaxKind.VariableDeclaration: return reparseVariableDeclaration(node as VariableDeclaration);
case SyntaxKind.BindingElement: return reparseBindingElement(node as BindingElement);
default: return visitEachChild(node, visitor, reparseContext);
}
}
function reparse<T extends Node>(node: T, parse: () => T): T | Expression;
function reparse<T extends Node>(node: T | undefined, parse: () => T): T | Expression | undefined;
function reparse<T extends Node>(node: T | undefined, parse: () => T) {
if (node && node.transformFlags & TransformFlags.ContainsPossibleTopLevelAwait) {
if (isExpression(node)) {
return speculationHelper(() => {
scanner.setTextPos(node.pos);
const savedContextFlags = contextFlags;
contextFlags = node.flags & NodeFlags.ContextFlags;
nextToken();
const result = doInAwaitContext(parse);
contextFlags = savedContextFlags;
return result;
}, SpeculationKind.Reparse);
}
return visitEachChild(node, visitor, reparseContext);
}
return node;
}
function update<T extends Node>(updated: T, original: T) {
if (updated !== original) {
setNodeFlags(updated, updated.flags | NodeFlags.AwaitContext);
}
return updated;
}
function reparseExpressionStatement(node: ExpressionStatement) {
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
}
function reparseReturnStatement(node: ReturnStatement) {
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
}
function reparseThrowStatement(node: ThrowStatement) {
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
}
function reparseIfStatement(node: IfStatement) {
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
}
function reparseSwitchStatement(node: SwitchStatement) {
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
}
function reparseWithStatement(node: WithStatement) {
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
}
function reparseDoStatement(node: DoStatement) {
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
}
function reparseWhileStatement(node: WhileStatement) {
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
}
function reparseForStatement(node: ForStatement) {
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
}
function reparseForInStatement(node: ForInStatement) {
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
}
function reparseForOfStatement(node: ForOfStatement) {
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
}
function reparseExportAssignment(node: ExportAssignment) {
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
}
function reparseExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
}
function reparseDecorator(node: Decorator) {
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
}
function reparseComputedPropertyName(node: ComputedPropertyName) {
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
}
function reparseVariableDeclaration(node: VariableDeclaration) {
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
}
function reparseBindingElement(node: BindingElement) {
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
}
}
export function fixupParentReferences(rootNode: Node) {
// normally parent references are set during binding. However, for clients that only need
// a syntax tree, and no semantic features, then the binding process is an unnecessary
@@ -1037,8 +1195,15 @@ namespace ts {
function createSourceFile(fileName: string, languageVersion: ScriptTarget, scriptKind: ScriptKind, isDeclarationFile: boolean, statements: readonly Statement[], endOfFileToken: EndOfFileToken, flags: NodeFlags): SourceFile {
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
// this is quite rare comparing to other nodes and createNode should be as fast as possible
const sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
let sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
setTextRangePosWidth(sourceFile, 0, sourceText.length);
setExternalModuleIndicator(sourceFile);
// If we parsed this as an external module, it may contain top-level await
if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & TransformFlags.ContainsPossibleTopLevelAwait) {
sourceFile = reparseTopLevelAwait(sourceFile);
}
sourceFile.text = sourceText;
sourceFile.bindDiagnostics = [];
sourceFile.bindSuggestionDiagnostics = undefined;
@@ -1270,7 +1435,7 @@ namespace ts {
return currentToken = scanner.scanJsxAttributeValue();
}
function speculationHelper<T>(callback: () => T, isLookAhead: boolean): T {
function speculationHelper<T>(callback: () => T, speculationKind: SpeculationKind): T {
// Keep track of the state we'll need to rollback to if lookahead fails (or if the
// caller asked us to always reset our state).
const saveToken = currentToken;
@@ -1286,7 +1451,7 @@ namespace ts {
// If we're only looking ahead, then tell the scanner to only lookahead as well.
// Otherwise, if we're actually speculatively parsing, then tell the scanner to do the
// same.
const result = isLookAhead
const result = speculationKind !== SpeculationKind.TryParse
? scanner.lookAhead(callback)
: scanner.tryScan(callback);
@@ -1294,9 +1459,11 @@ namespace ts {
// If our callback returned something 'falsy' or we're just looking ahead,
// then unconditionally restore us to where we were.
if (!result || isLookAhead) {
if (!result || speculationKind !== SpeculationKind.TryParse) {
currentToken = saveToken;
parseDiagnostics.length = saveParseDiagnosticsLength;
if (speculationKind !== SpeculationKind.Reparse) {
parseDiagnostics.length = saveParseDiagnosticsLength;
}
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
}
@@ -1308,7 +1475,7 @@ namespace ts {
* is returned from this function.
*/
function lookAhead<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookAhead*/ true);
return speculationHelper(callback, SpeculationKind.Lookahead);
}
/** Invokes the provided callback. If the callback returns something falsy, then it restores
@@ -1317,7 +1484,7 @@ namespace ts {
* of invoking the callback is returned from this function.
*/
function tryParse<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookAhead*/ false);
return speculationHelper(callback, SpeculationKind.TryParse);
}
// Ignore strict mode flag because we will report an error in type checker instead.
@@ -3789,7 +3956,6 @@ namespace ts {
function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, asyncModifier?: NodeArray<Modifier> | undefined): ArrowFunction {
Debug.assert(token() === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
const parameter = factory.createParameterDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
@@ -3805,7 +3971,6 @@ namespace ts {
const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken);
const body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
const node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
return addJSDocComment(finishNode(node, pos));
}
@@ -4061,7 +4226,7 @@ namespace ts {
const hasJSDocFunctionType = type && isJSDocFunctionType(type);
if (!allowAmbiguity && token() !== SyntaxKind.EqualsGreaterThanToken && (hasJSDocFunctionType || token() !== SyntaxKind.OpenBraceToken)) {
// Returning undefined here will cause our caller to rewind to where we started from.
return undefined;
return undefined;
}
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
@@ -5497,12 +5662,15 @@ namespace ts {
// Because of automatic semicolon insertion, we need to report error if this
// throw could be terminated with a semicolon. Note: we can't call 'parseExpression'
// directly as that might consume an expression on the following line.
// We just return 'undefined' in that case. The actual error will be reported in the
// grammar walker.
// TODO(rbuckton): Should we use `createMissingNode` here instead?
const expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
// Instead, we create a "missing" identifier, but don't report an error. The actual error
// will be reported in the grammar walker.
let expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
if (expression === undefined) {
identifierCount++;
expression = finishNode(factory.createIdentifier(""), getNodePos());
}
parseSemicolon();
return finishNode(factory.createThrowStatement(expression!), pos);
return finishNode(factory.createThrowStatement(expression), pos);
}
// TODO: Review for error recovery
@@ -6065,16 +6233,20 @@ namespace ts {
}
function parseFunctionDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): FunctionDeclaration {
const savedAwaitContext = inAwaitContext();
const modifierFlags = modifiersToFlags(modifiers);
parseExpected(SyntaxKind.FunctionKeyword);
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
const name = modifierFlags & ModifierFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None;
const isAsync = modifierFlags & ModifierFlags.Async ? SignatureFlags.Await : SignatureFlags.None;
const typeParameters = parseTypeParameters();
if (modifierFlags & ModifierFlags.Export) setAwaitContext(/*value*/ true);
const parameters = parseParameters(isGenerator | isAsync);
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected);
setAwaitContext(savedAwaitContext);
const node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
@@ -6390,9 +6562,12 @@ namespace ts {
}
function parseClassDeclarationOrExpression(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined, kind: ClassLikeDeclaration["kind"]): ClassLikeDeclaration {
const savedAwaitContext = inAwaitContext();
parseExpected(SyntaxKind.ClassKeyword);
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
const name = parseNameOfClassDeclarationOrExpression();
const typeParameters = parseTypeParameters();
if (some(modifiers, isExportModifier)) setAwaitContext(/*value*/ true);
const heritageClauses = parseHeritageClauses();
let members;
@@ -6405,7 +6580,7 @@ namespace ts {
else {
members = createMissingList<ClassElement>();
}
setAwaitContext(savedAwaitContext);
const node = kind === SyntaxKind.ClassDeclaration
? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members)
: factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members);
@@ -6608,8 +6783,10 @@ namespace ts {
function parseImportDeclarationOrImportEqualsDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): ImportEqualsDeclaration | ImportDeclaration {
parseExpected(SyntaxKind.ImportKeyword);
const afterImportPos = scanner.getStartPos();
// We don't parse the identifier here in await context, instead we will report a grammar error in the checker.
let identifier: Identifier | undefined;
if (isIdentifier()) {
identifier = parseIdentifier();
@@ -6792,6 +6969,8 @@ namespace ts {
}
function parseExportDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): ExportDeclaration {
const savedAwaitContext = inAwaitContext();
setAwaitContext(/*value*/ true);
let exportClause: NamedExportBindings | undefined;
let moduleSpecifier: Expression | undefined;
const isTypeOnly = parseOptional(SyntaxKind.TypeKeyword);
@@ -6814,11 +6993,14 @@ namespace ts {
}
}
parseSemicolon();
setAwaitContext(savedAwaitContext);
const node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parseExportAssignment(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): ExportAssignment {
const savedAwaitContext = inAwaitContext();
setAwaitContext(/*value*/ true);
let isExportEquals: boolean | undefined;
if (parseOptional(SyntaxKind.EqualsToken)) {
isExportEquals = true;
@@ -6828,6 +7010,7 @@ namespace ts {
}
const expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
setAwaitContext(savedAwaitContext);
const node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
@@ -7860,6 +8043,7 @@ namespace ts {
const incrementalSourceFile = <IncrementalNode><Node>sourceFile;
Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
incrementalSourceFile.hasBeenIncrementallyParsed = true;
Parser.fixupParentReferences(incrementalSourceFile);
const oldText = sourceFile.text;
const syntaxCursor = createSyntaxCursor(sourceFile);
@@ -8098,8 +8282,8 @@ namespace ts {
Debug.assert(pos <= end);
if (element.parent) {
Debug.assert(pos >= element.parent.pos);
Debug.assert(end <= element.parent.end);
Debug.assertGreaterThanOrEqual(pos, element.parent.pos);
Debug.assertLessThanOrEqual(end, element.parent.end);
}
setTextRangePosEnd(element, pos, end);
+6 -5
View File
@@ -2726,7 +2726,7 @@ namespace ts {
export interface ThrowStatement extends Statement {
readonly kind: SyntaxKind.ThrowStatement;
readonly expression?: Expression;
readonly expression: Expression;
}
export interface TryStatement extends Statement {
@@ -6258,6 +6258,7 @@ namespace ts {
ContainsHoistedDeclarationOrCompletion = 1 << 20,
ContainsDynamicImport = 1 << 21,
ContainsClassFields = 1 << 22,
ContainsPossibleTopLevelAwait = 1 << 23,
// Please leave this as 1 << 29.
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
@@ -6284,13 +6285,13 @@ namespace ts {
OuterExpressionExcludes = HasComputedFlags,
PropertyAccessExcludes = OuterExpressionExcludes,
NodeExcludes = PropertyAccessExcludes,
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
MethodOrAccessorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
PropertyExcludes = NodeExcludes | ContainsLexicalThis,
ClassExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName,
ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion,
ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion | ContainsPossibleTopLevelAwait,
TypeExcludes = ~ContainsTypeScript,
ObjectLiteralExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName | ContainsObjectRestOrSpread,
ArrayLiteralOrCallOrNewExcludes = NodeExcludes | ContainsRestOrSpread,
+1 -1
View File
@@ -838,7 +838,7 @@ namespace ts {
case SyntaxKind.ThrowStatement:
return factory.updateThrowStatement(<ThrowStatement>node,
nodeVisitor((<ThrowStatement>node).expression!, visitor, isExpression)); // expression could be `undefined` due to invalid parse.
nodeVisitor((<ThrowStatement>node).expression, visitor, isExpression));
case SyntaxKind.TryStatement:
return factory.updateTryStatement(<TryStatement>node,
+1 -1
View File
@@ -1447,7 +1447,7 @@ declare namespace ts {
}
export interface ThrowStatement extends Statement {
readonly kind: SyntaxKind.ThrowStatement;
readonly expression?: Expression;
readonly expression: Expression;
}
export interface TryStatement extends Statement {
readonly kind: SyntaxKind.TryStatement;
+1 -1
View File
@@ -1447,7 +1447,7 @@ declare namespace ts {
}
export interface ThrowStatement extends Statement {
readonly kind: SyntaxKind.ThrowStatement;
readonly expression?: Expression;
readonly expression: Expression;
}
export interface TryStatement extends Statement {
readonly kind: SyntaxKind.TryStatement;
@@ -0,0 +1,43 @@
tests/cases/compiler/a.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/compiler/asyncawait.ts(2,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/compiler/c.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/compiler/d.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/compiler/e.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/compiler/asyncawait.ts (1 errors) ====
export function async<T>(...args: any[]): any { }
export function await(...args: any[]): any { }
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/compiler/a.ts (1 errors) ====
import { async, await } from 'asyncawait';
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
export default async(() => await(Promise.resolve(1)));
==== tests/cases/compiler/b.ts (0 errors) ====
export default async () => { return 0; };
==== tests/cases/compiler/c.ts (1 errors) ====
import { async, await } from 'asyncawait';
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
export default async<number>();
==== tests/cases/compiler/d.ts (1 errors) ====
import { async, await } from 'asyncawait';
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
export default async;
==== tests/cases/compiler/e.ts (1 errors) ====
import { async, await } from 'asyncawait';
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
export default async
export function foo() { }
@@ -3,5 +3,5 @@ throw
a;
//// [throwWithoutNewLine2.js]
throw;
throw ;
a;
@@ -1,5 +1,6 @@
=== tests/cases/compiler/throwWithoutNewLine2.ts ===
throw
a;
> : any
>a : any
@@ -1,9 +0,0 @@
tests/cases/conformance/externalModules/topLevelAwait.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
==== tests/cases/conformance/externalModules/topLevelAwait.ts (1 errors) ====
export const x = 1;
await x;
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
@@ -1,8 +0,0 @@
//// [topLevelAwait.ts]
export const x = 1;
await x;
//// [topLevelAwait.js]
export const x = 1;
await x;
@@ -1,7 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
await x;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
@@ -1,9 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
@@ -1,8 +0,0 @@
//// [topLevelAwait.ts]
export const x = 1;
await x;
//// [topLevelAwait.js]
export const x = 1;
await x;
@@ -1,7 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
await x;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
@@ -1,9 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
@@ -1,9 +0,0 @@
tests/cases/conformance/externalModules/topLevelAwait.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
==== tests/cases/conformance/externalModules/topLevelAwait.ts (1 errors) ====
export const x = 1;
await x;
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
@@ -1,18 +0,0 @@
//// [topLevelAwait.ts]
export const x = 1;
await x;
//// [topLevelAwait.js]
System.register([], function (exports_1, context_1) {
"use strict";
var x;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: async function () {
exports_1("x", x = 1);
await x;
}
};
});
@@ -1,7 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
await x;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
@@ -1,9 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
@@ -1,18 +0,0 @@
//// [topLevelAwait.ts]
export const x = 1;
await x;
//// [topLevelAwait.js]
System.register([], function (exports_1, context_1) {
"use strict";
var x;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: async function () {
exports_1("x", x = 1);
await x;
}
};
});
@@ -1,7 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
await x;
>x : Symbol(x, Decl(topLevelAwait.ts, 0, 12))
@@ -1,9 +0,0 @@
=== tests/cases/conformance/externalModules/topLevelAwait.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
@@ -0,0 +1,66 @@
tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
==== tests/cases/conformance/externalModules/index.ts (2 errors) ====
export const x = 1;
await x;
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
const _await = 1;
// await allowed in aliased export
export { _await as await };
@@ -0,0 +1,108 @@
//// [tests/cases/conformance/externalModules/topLevelAwait.1.ts] ////
//// [index.ts]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
//// [other.ts]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [other.js]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [index.js]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
await (x);
await (f(), x);
await (x);
await (f(), x);
// reparse tagged template as await
await ``;
await ``;
// member names should be ok
class C1 {
await() { }
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
constructor() {
this.await = 1;
}
}
({
await() { }
});
({
get await() { return 1; },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
let C = class C {
};
C = __decorate([
(await dec)
], C);
@@ -0,0 +1,113 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : Symbol(x, Decl(index.ts, 0, 12))
await x;
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse element access as await
await [x];
>x : Symbol(x, Decl(index.ts, 0, 12))
await [x, x];
>x : Symbol(x, Decl(index.ts, 0, 12))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse call as await
declare function f(): number;
>f : Symbol(f, Decl(index.ts, 5, 13))
await (x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await (f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
await() {}
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
}
class C2 {
>C2 : Symbol(C2, Decl(index.ts, 21, 1))
get await() { return 1; }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
set await(value) { }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
>value : Symbol(value, Decl(index.ts, 24, 14))
}
class C3 {
>C3 : Symbol(C3, Decl(index.ts, 25, 1))
await = 1;
>await : Symbol(C3.await, Decl(index.ts, 26, 10))
}
({
await() {}
>await : Symbol(await, Decl(index.ts, 29, 2))
});
({
get await() { return 1 },
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
set await(value) { }
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
>value : Symbol(value, Decl(index.ts, 34, 14))
});
({
await: 1
>await : Symbol(await, Decl(index.ts, 36, 2))
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : Symbol(C1.await, Decl(index.ts, 19, 10))
>C1.prototype : Symbol(C1.prototype)
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
>prototype : Symbol(C1.prototype)
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
// await in decorators
declare const dec: any;
>dec : Symbol(dec, Decl(index.ts, 44, 13))
@(await dec)
>dec : Symbol(dec, Decl(index.ts, 44, 13))
class C {
>C : Symbol(C, Decl(index.ts, 44, 23))
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : Symbol(await, Decl(other.ts, 3, 8))
>_await : Symbol(_await, Decl(index.ts, 50, 8))
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : Symbol(_await, Decl(other.ts, 0, 5))
// await allowed in aliased export
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 5))
>await : Symbol(await, Decl(other.ts, 3, 8))
@@ -0,0 +1,155 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
// reparse element access as await
await [x];
>await [x] : number[]
>[x] : number[]
>x : 1
await [x, x];
>await [x, x] : number[]
>[x, x] : number[]
>x : 1
>x : 1
// reparse call as await
declare function f(): number;
>f : () => number
await (x);
>await (x) : 1
>(x) : 1
>x : 1
await (f(), x);
>await (f(), x) : 1
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
await <number>(x);
>await <number>(x) : number
><number>(x) : number
>(x) : 1
>x : 1
await <number>(f(), x);
>await <number>(f(), x) : number
><number>(f(), x) : number
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
// reparse tagged template as await
await ``;
>await `` : ""
>`` : ""
await <string> ``;
>await <string> `` : string
><string> `` : string
>`` : ""
// member names should be ok
class C1 {
>C1 : C1
await() {}
>await : () => void
}
class C2 {
>C2 : C2
get await() { return 1; }
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
}
class C3 {
>C3 : C3
await = 1;
>await : number
>1 : 1
}
({
>({ await() {}}) : { await(): void; }
>{ await() {}} : { await(): void; }
await() {}
>await : () => void
});
({
>({ get await() { return 1 }, set await(value) { }}) : { await: number; }
>{ get await() { return 1 }, set await(value) { }} : { await: number; }
get await() { return 1 },
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
});
({
>({ await: 1}) : { await: number; }
>{ await: 1} : { await: number; }
await: 1
>await : number
>1 : 1
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : () => void
>C1.prototype : C1
>C1 : typeof C1
>prototype : C1
>await : () => void
// await in decorators
declare const dec: any;
>dec : any
@(await dec)
>(await dec) : any
>await dec : any
>dec : any
class C {
>C : C
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : 1
>_await : 1
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : 1
>1 : 1
// await allowed in aliased export
export { _await as await };
>_await : 1
>await : 1
@@ -0,0 +1,108 @@
//// [tests/cases/conformance/externalModules/topLevelAwait.1.ts] ////
//// [index.ts]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
//// [other.ts]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [other.js]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [index.js]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
await (x);
await (f(), x);
await (x);
await (f(), x);
// reparse tagged template as await
await ``;
await ``;
// member names should be ok
class C1 {
await() { }
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
constructor() {
this.await = 1;
}
}
({
await() { }
});
({
get await() { return 1; },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
let C = class C {
};
C = __decorate([
(await dec)
], C);
@@ -0,0 +1,113 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : Symbol(x, Decl(index.ts, 0, 12))
await x;
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse element access as await
await [x];
>x : Symbol(x, Decl(index.ts, 0, 12))
await [x, x];
>x : Symbol(x, Decl(index.ts, 0, 12))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse call as await
declare function f(): number;
>f : Symbol(f, Decl(index.ts, 5, 13))
await (x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await (f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
await() {}
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
}
class C2 {
>C2 : Symbol(C2, Decl(index.ts, 21, 1))
get await() { return 1; }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
set await(value) { }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
>value : Symbol(value, Decl(index.ts, 24, 14))
}
class C3 {
>C3 : Symbol(C3, Decl(index.ts, 25, 1))
await = 1;
>await : Symbol(C3.await, Decl(index.ts, 26, 10))
}
({
await() {}
>await : Symbol(await, Decl(index.ts, 29, 2))
});
({
get await() { return 1 },
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
set await(value) { }
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
>value : Symbol(value, Decl(index.ts, 34, 14))
});
({
await: 1
>await : Symbol(await, Decl(index.ts, 36, 2))
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : Symbol(C1.await, Decl(index.ts, 19, 10))
>C1.prototype : Symbol(C1.prototype)
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
>prototype : Symbol(C1.prototype)
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
// await in decorators
declare const dec: any;
>dec : Symbol(dec, Decl(index.ts, 44, 13))
@(await dec)
>dec : Symbol(dec, Decl(index.ts, 44, 13))
class C {
>C : Symbol(C, Decl(index.ts, 44, 23))
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : Symbol(await, Decl(other.ts, 3, 8))
>_await : Symbol(_await, Decl(index.ts, 50, 8))
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : Symbol(_await, Decl(other.ts, 0, 5))
// await allowed in aliased export
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 5))
>await : Symbol(await, Decl(other.ts, 3, 8))
@@ -0,0 +1,155 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
// reparse element access as await
await [x];
>await [x] : number[]
>[x] : number[]
>x : 1
await [x, x];
>await [x, x] : number[]
>[x, x] : number[]
>x : 1
>x : 1
// reparse call as await
declare function f(): number;
>f : () => number
await (x);
>await (x) : 1
>(x) : 1
>x : 1
await (f(), x);
>await (f(), x) : 1
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
await <number>(x);
>await <number>(x) : number
><number>(x) : number
>(x) : 1
>x : 1
await <number>(f(), x);
>await <number>(f(), x) : number
><number>(f(), x) : number
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
// reparse tagged template as await
await ``;
>await `` : ""
>`` : ""
await <string> ``;
>await <string> `` : string
><string> `` : string
>`` : ""
// member names should be ok
class C1 {
>C1 : C1
await() {}
>await : () => void
}
class C2 {
>C2 : C2
get await() { return 1; }
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
}
class C3 {
>C3 : C3
await = 1;
>await : number
>1 : 1
}
({
>({ await() {}}) : { await(): void; }
>{ await() {}} : { await(): void; }
await() {}
>await : () => void
});
({
>({ get await() { return 1 }, set await(value) { }}) : { await: number; }
>{ get await() { return 1 }, set await(value) { }} : { await: number; }
get await() { return 1 },
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
});
({
>({ await: 1}) : { await: number; }
>{ await: 1} : { await: number; }
await: 1
>await : number
>1 : 1
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : () => void
>C1.prototype : C1
>C1 : typeof C1
>prototype : C1
>await : () => void
// await in decorators
declare const dec: any;
>dec : any
@(await dec)
>(await dec) : any
>await dec : any
>dec : any
class C {
>C : C
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : 1
>_await : 1
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : 1
>1 : 1
// await allowed in aliased export
export { _await as await };
>_await : 1
>await : 1
@@ -0,0 +1,66 @@
tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
==== tests/cases/conformance/externalModules/index.ts (2 errors) ====
export const x = 1;
await x;
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
~~~~~
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
const _await = 1;
// await allowed in aliased export
export { _await as await };
@@ -0,0 +1,127 @@
//// [tests/cases/conformance/externalModules/topLevelAwait.1.ts] ////
//// [index.ts]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
//// [other.ts]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [other.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _await;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
_await = 1;
exports_1("await", _await);
}
};
});
//// [index.js]
System.register([], function (exports_1, context_1) {
"use strict";
var x, C1, C2, C3, C;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: async function () {
exports_1("x", x = 1);
await x;
// reparse element access as await
await [x];
await [x, x];
await (x);
await (f(), x);
await (x);
await (f(), x);
// reparse tagged template as await
await ``;
await ``;
// member names should be ok
C1 = class C1 {
await() { }
};
C2 = class C2 {
get await() { return 1; }
set await(value) { }
};
C3 = class C3 {
constructor() {
this.await = 1;
}
};
({
await() { }
});
({
get await() { return 1; },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
C = class C {
};
C = __decorate([
(await dec)
], C);
}
};
});
@@ -0,0 +1,113 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : Symbol(x, Decl(index.ts, 0, 12))
await x;
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse element access as await
await [x];
>x : Symbol(x, Decl(index.ts, 0, 12))
await [x, x];
>x : Symbol(x, Decl(index.ts, 0, 12))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse call as await
declare function f(): number;
>f : Symbol(f, Decl(index.ts, 5, 13))
await (x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await (f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
await() {}
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
}
class C2 {
>C2 : Symbol(C2, Decl(index.ts, 21, 1))
get await() { return 1; }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
set await(value) { }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
>value : Symbol(value, Decl(index.ts, 24, 14))
}
class C3 {
>C3 : Symbol(C3, Decl(index.ts, 25, 1))
await = 1;
>await : Symbol(C3.await, Decl(index.ts, 26, 10))
}
({
await() {}
>await : Symbol(await, Decl(index.ts, 29, 2))
});
({
get await() { return 1 },
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
set await(value) { }
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
>value : Symbol(value, Decl(index.ts, 34, 14))
});
({
await: 1
>await : Symbol(await, Decl(index.ts, 36, 2))
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : Symbol(C1.await, Decl(index.ts, 19, 10))
>C1.prototype : Symbol(C1.prototype)
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
>prototype : Symbol(C1.prototype)
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
// await in decorators
declare const dec: any;
>dec : Symbol(dec, Decl(index.ts, 44, 13))
@(await dec)
>dec : Symbol(dec, Decl(index.ts, 44, 13))
class C {
>C : Symbol(C, Decl(index.ts, 44, 23))
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : Symbol(await, Decl(other.ts, 3, 8))
>_await : Symbol(_await, Decl(index.ts, 50, 8))
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : Symbol(_await, Decl(other.ts, 0, 5))
// await allowed in aliased export
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 5))
>await : Symbol(await, Decl(other.ts, 3, 8))
@@ -0,0 +1,155 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
// reparse element access as await
await [x];
>await [x] : number[]
>[x] : number[]
>x : 1
await [x, x];
>await [x, x] : number[]
>[x, x] : number[]
>x : 1
>x : 1
// reparse call as await
declare function f(): number;
>f : () => number
await (x);
>await (x) : 1
>(x) : 1
>x : 1
await (f(), x);
>await (f(), x) : 1
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
await <number>(x);
>await <number>(x) : number
><number>(x) : number
>(x) : 1
>x : 1
await <number>(f(), x);
>await <number>(f(), x) : number
><number>(f(), x) : number
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
// reparse tagged template as await
await ``;
>await `` : ""
>`` : ""
await <string> ``;
>await <string> `` : string
><string> `` : string
>`` : ""
// member names should be ok
class C1 {
>C1 : C1
await() {}
>await : () => void
}
class C2 {
>C2 : C2
get await() { return 1; }
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
}
class C3 {
>C3 : C3
await = 1;
>await : number
>1 : 1
}
({
>({ await() {}}) : { await(): void; }
>{ await() {}} : { await(): void; }
await() {}
>await : () => void
});
({
>({ get await() { return 1 }, set await(value) { }}) : { await: number; }
>{ get await() { return 1 }, set await(value) { }} : { await: number; }
get await() { return 1 },
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
});
({
>({ await: 1}) : { await: number; }
>{ await: 1} : { await: number; }
await: 1
>await : number
>1 : 1
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : () => void
>C1.prototype : C1
>C1 : typeof C1
>prototype : C1
>await : () => void
// await in decorators
declare const dec: any;
>dec : any
@(await dec)
>(await dec) : any
>await dec : any
>dec : any
class C {
>C : C
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : 1
>_await : 1
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : 1
>1 : 1
// await allowed in aliased export
export { _await as await };
>_await : 1
>await : 1
@@ -0,0 +1,127 @@
//// [tests/cases/conformance/externalModules/topLevelAwait.1.ts] ////
//// [index.ts]
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
//// [other.ts]
const _await = 1;
// await allowed in aliased export
export { _await as await };
//// [other.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _await;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
_await = 1;
exports_1("await", _await);
}
};
});
//// [index.js]
System.register([], function (exports_1, context_1) {
"use strict";
var x, C1, C2, C3, C;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: async function () {
exports_1("x", x = 1);
await x;
// reparse element access as await
await [x];
await [x, x];
await (x);
await (f(), x);
await (x);
await (f(), x);
// reparse tagged template as await
await ``;
await ``;
// member names should be ok
C1 = class C1 {
await() { }
};
C2 = class C2 {
get await() { return 1; }
set await(value) { }
};
C3 = class C3 {
constructor() {
this.await = 1;
}
};
({
await() { }
});
({
get await() { return 1; },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
C = class C {
};
C = __decorate([
(await dec)
], C);
}
};
});
@@ -0,0 +1,113 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : Symbol(x, Decl(index.ts, 0, 12))
await x;
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse element access as await
await [x];
>x : Symbol(x, Decl(index.ts, 0, 12))
await [x, x];
>x : Symbol(x, Decl(index.ts, 0, 12))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse call as await
declare function f(): number;
>f : Symbol(f, Decl(index.ts, 5, 13))
await (x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await (f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(x);
>x : Symbol(x, Decl(index.ts, 0, 12))
await <number>(f(), x);
>f : Symbol(f, Decl(index.ts, 5, 13))
>x : Symbol(x, Decl(index.ts, 0, 12))
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
await() {}
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
}
class C2 {
>C2 : Symbol(C2, Decl(index.ts, 21, 1))
get await() { return 1; }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
set await(value) { }
>await : Symbol(C2.await, Decl(index.ts, 22, 10), Decl(index.ts, 23, 29))
>value : Symbol(value, Decl(index.ts, 24, 14))
}
class C3 {
>C3 : Symbol(C3, Decl(index.ts, 25, 1))
await = 1;
>await : Symbol(C3.await, Decl(index.ts, 26, 10))
}
({
await() {}
>await : Symbol(await, Decl(index.ts, 29, 2))
});
({
get await() { return 1 },
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
set await(value) { }
>await : Symbol(await, Decl(index.ts, 32, 2), Decl(index.ts, 33, 29))
>value : Symbol(value, Decl(index.ts, 34, 14))
});
({
await: 1
>await : Symbol(await, Decl(index.ts, 36, 2))
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : Symbol(C1.await, Decl(index.ts, 19, 10))
>C1.prototype : Symbol(C1.prototype)
>C1 : Symbol(C1, Decl(index.ts, 16, 18))
>prototype : Symbol(C1.prototype)
>await : Symbol(C1.await, Decl(index.ts, 19, 10))
// await in decorators
declare const dec: any;
>dec : Symbol(dec, Decl(index.ts, 44, 13))
@(await dec)
>dec : Symbol(dec, Decl(index.ts, 44, 13))
class C {
>C : Symbol(C, Decl(index.ts, 44, 23))
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : Symbol(await, Decl(other.ts, 3, 8))
>_await : Symbol(_await, Decl(index.ts, 50, 8))
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : Symbol(_await, Decl(other.ts, 0, 5))
// await allowed in aliased export
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 5))
>await : Symbol(await, Decl(other.ts, 3, 8))
@@ -0,0 +1,155 @@
=== tests/cases/conformance/externalModules/index.ts ===
export const x = 1;
>x : 1
>1 : 1
await x;
>await x : 1
>x : 1
// reparse element access as await
await [x];
>await [x] : number[]
>[x] : number[]
>x : 1
await [x, x];
>await [x, x] : number[]
>[x, x] : number[]
>x : 1
>x : 1
// reparse call as await
declare function f(): number;
>f : () => number
await (x);
>await (x) : 1
>(x) : 1
>x : 1
await (f(), x);
>await (f(), x) : 1
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
await <number>(x);
>await <number>(x) : number
><number>(x) : number
>(x) : 1
>x : 1
await <number>(f(), x);
>await <number>(f(), x) : number
><number>(f(), x) : number
>(f(), x) : 1
>f(), x : 1
>f() : number
>f : () => number
>x : 1
// reparse tagged template as await
await ``;
>await `` : ""
>`` : ""
await <string> ``;
>await <string> `` : string
><string> `` : string
>`` : ""
// member names should be ok
class C1 {
>C1 : C1
await() {}
>await : () => void
}
class C2 {
>C2 : C2
get await() { return 1; }
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
}
class C3 {
>C3 : C3
await = 1;
>await : number
>1 : 1
}
({
>({ await() {}}) : { await(): void; }
>{ await() {}} : { await(): void; }
await() {}
>await : () => void
});
({
>({ get await() { return 1 }, set await(value) { }}) : { await: number; }
>{ get await() { return 1 }, set await(value) { }} : { await: number; }
get await() { return 1 },
>await : number
>1 : 1
set await(value) { }
>await : number
>value : number
});
({
>({ await: 1}) : { await: number; }
>{ await: 1} : { await: number; }
await: 1
>await : number
>1 : 1
});
// property access name should be ok
C1.prototype.await;
>C1.prototype.await : () => void
>C1.prototype : C1
>C1 : typeof C1
>prototype : C1
>await : () => void
// await in decorators
declare const dec: any;
>dec : any
@(await dec)
>(await dec) : any
>await dec : any
>dec : any
class C {
>C : C
}
// await allowed in aliased import
import { await as _await } from "./other";
>await : 1
>_await : 1
=== tests/cases/conformance/externalModules/other.ts ===
const _await = 1;
>_await : 1
>1 : 1
// await allowed in aliased export
export { _await as await };
>_await : 1
>await : 1
@@ -0,0 +1,10 @@
//// [topLevelAwait.2.ts]
declare namespace foo { const await: any; }
// await allowed in import=namespace when not a module
import await = foo.await;
//// [topLevelAwait.2.js]
// await allowed in import=namespace when not a module
var await = foo.await;
@@ -0,0 +1,11 @@
=== tests/cases/conformance/externalModules/topLevelAwait.2.ts ===
declare namespace foo { const await: any; }
>foo : Symbol(foo, Decl(topLevelAwait.2.ts, 0, 0))
>await : Symbol(await, Decl(topLevelAwait.2.ts, 0, 29))
// await allowed in import=namespace when not a module
import await = foo.await;
>await : Symbol(await, Decl(topLevelAwait.2.ts, 0, 43))
>foo : Symbol(foo, Decl(topLevelAwait.2.ts, 0, 0))
>await : Symbol(await, Decl(topLevelAwait.2.ts, 0, 29))
@@ -0,0 +1,11 @@
=== tests/cases/conformance/externalModules/topLevelAwait.2.ts ===
declare namespace foo { const await: any; }
>foo : typeof foo
>await : any
// await allowed in import=namespace when not a module
import await = foo.await;
>await : any
>foo : typeof foo
>await : any
@@ -0,0 +1,10 @@
=== tests/cases/conformance/externalModules/index.d.ts ===
// await keyword allowed as identifier in a declaration file
export {};
declare const await: any;
>await : Symbol(await, Decl(index.d.ts, 2, 13))
declare class C extends await {}
>C : Symbol(C, Decl(index.d.ts, 2, 25))
>await : Symbol(await, Decl(index.d.ts, 2, 13))
@@ -0,0 +1,10 @@
=== tests/cases/conformance/externalModules/index.d.ts ===
// await keyword allowed as identifier in a declaration file
export {};
declare const await: any;
>await : any
declare class C extends await {}
>C : C
>await : any
@@ -0,0 +1,95 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(4,8): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(4,10): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(5,14): error TS1005: '>' expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(5,16): error TS2693: 'string' only refers to a type, but is being used as a value here.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(8,14): error TS1005: '>' expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(8,16): error TS2693: 'string' only refers to a type, but is being used as a value here.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(11,17): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(15,8): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(18,2): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(21,2): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(26,6): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(30,6): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(34,12): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(40,14): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(41,14): error TS1109: Expression expected.
tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(42,20): error TS1109: Expression expected.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts (16 errors) ====
export {};
// reparse call as invalid await should error
await (1,);
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~
!!! error TS1109: Expression expected.
await <number, string>(1);
~
!!! error TS1005: '>' expected.
~~~~~~
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
// reparse tagged template as invalid await should error
await <number, string> ``;
~
!!! error TS1005: '>' expected.
~~~~~~
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
// reparse class extends clause should fail
class C extends await<string> {
~~~~~
!!! error TS1109: Expression expected.
}
// await in class decorators should fail
@(await)
~
!!! error TS1109: Expression expected.
class C1 {}
@await(x)
~~~~~
!!! error TS1109: Expression expected.
class C2 {}
@await
~~~~~
!!! error TS1109: Expression expected.
class C3 {}
// await in member decorators should fail
class C4 {
@await
~~~~~
!!! error TS1109: Expression expected.
["foo"]() {}
}
class C5 {
@await(1)
~~~~~
!!! error TS1109: Expression expected.
["foo"]() {}
}
class C6 {
@(await)
~
!!! error TS1109: Expression expected.
["foo"]() {}
}
// await in parameter decorators should fail
class C7 {
method1(@await [x]) {}
~~~~~
!!! error TS1109: Expression expected.
method2(@await(1) [x]) {}
~~~~~
!!! error TS1109: Expression expected.
method3(@(await) [x]) {}
~
!!! error TS1109: Expression expected.
}
@@ -0,0 +1,102 @@
//// [topLevelAwaitErrors.1.ts]
export {};
// reparse call as invalid await should error
await (1,);
await <number, string>(1);
// reparse tagged template as invalid await should error
await <number, string> ``;
// reparse class extends clause should fail
class C extends await<string> {
}
// await in class decorators should fail
@(await)
class C1 {}
@await(x)
class C2 {}
@await
class C3 {}
// await in member decorators should fail
class C4 {
@await
["foo"]() {}
}
class C5 {
@await(1)
["foo"]() {}
}
class C6 {
@(await)
["foo"]() {}
}
// await in parameter decorators should fail
class C7 {
method1(@await [x]) {}
method2(@await(1) [x]) {}
method3(@(await) [x]) {}
}
//// [topLevelAwaitErrors.1.js]
// reparse call as invalid await should error
await (1, );
await , string > (1);
// reparse tagged template as invalid await should error
await , string > ``;
// reparse class extends clause should fail
class C extends {
}
// await in class decorators should fail
let C1 = class C1 {
};
C1 = __decorate([
(await )
], C1);
let C2 = class C2 {
};
C2 = __decorate([
], C2);
let C3 = class C3 {
};
C3 = __decorate([
], C3);
// await in member decorators should fail
class C4 {
["foo"]() { }
}
__decorate([
], C4.prototype, "foo", null);
class C5 {
["foo"]() { }
}
__decorate([
], C5.prototype, "foo", null);
class C6 {
["foo"]() { }
}
__decorate([
(await )
], C6.prototype, "foo", null);
// await in parameter decorators should fail
class C7 {
method1([x]) { }
method2([x]) { }
method3([x]) { }
}
__decorate([
__param(0, )
], C7.prototype, "method1", null);
__decorate([
__param(0, )
], C7.prototype, "method2", null);
__decorate([
__param(0, (await ))
], C7.prototype, "method3", null);
export {};
@@ -0,0 +1,71 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts ===
export {};
// reparse call as invalid await should error
await (1,);
await <number, string>(1);
// reparse tagged template as invalid await should error
await <number, string> ``;
// reparse class extends clause should fail
class C extends await<string> {
>C : Symbol(C, Decl(topLevelAwaitErrors.1.ts, 7, 26))
}
// await in class decorators should fail
@(await)
class C1 {}
>C1 : Symbol(C1, Decl(topLevelAwaitErrors.1.ts, 11, 1))
@await(x)
class C2 {}
>C2 : Symbol(C2, Decl(topLevelAwaitErrors.1.ts, 15, 11))
@await
class C3 {}
>C3 : Symbol(C3, Decl(topLevelAwaitErrors.1.ts, 18, 11))
// await in member decorators should fail
class C4 {
>C4 : Symbol(C4, Decl(topLevelAwaitErrors.1.ts, 21, 11))
@await
["foo"]() {}
>["foo"] : Symbol(C4["foo"], Decl(topLevelAwaitErrors.1.ts, 24, 10))
>"foo" : Symbol(C4["foo"], Decl(topLevelAwaitErrors.1.ts, 24, 10))
}
class C5 {
>C5 : Symbol(C5, Decl(topLevelAwaitErrors.1.ts, 27, 1))
@await(1)
["foo"]() {}
>["foo"] : Symbol(C5["foo"], Decl(topLevelAwaitErrors.1.ts, 28, 10))
>"foo" : Symbol(C5["foo"], Decl(topLevelAwaitErrors.1.ts, 28, 10))
}
class C6 {
>C6 : Symbol(C6, Decl(topLevelAwaitErrors.1.ts, 31, 1))
@(await)
["foo"]() {}
>["foo"] : Symbol(C6["foo"], Decl(topLevelAwaitErrors.1.ts, 32, 10))
>"foo" : Symbol(C6["foo"], Decl(topLevelAwaitErrors.1.ts, 32, 10))
}
// await in parameter decorators should fail
class C7 {
>C7 : Symbol(C7, Decl(topLevelAwaitErrors.1.ts, 35, 1))
method1(@await [x]) {}
>method1 : Symbol(C7.method1, Decl(topLevelAwaitErrors.1.ts, 38, 10))
>x : Symbol(x, Decl(topLevelAwaitErrors.1.ts, 39, 20))
method2(@await(1) [x]) {}
>method2 : Symbol(C7.method2, Decl(topLevelAwaitErrors.1.ts, 39, 26))
>x : Symbol(x, Decl(topLevelAwaitErrors.1.ts, 40, 23))
method3(@(await) [x]) {}
>method3 : Symbol(C7.method3, Decl(topLevelAwaitErrors.1.ts, 40, 29))
>x : Symbol(x, Decl(topLevelAwaitErrors.1.ts, 41, 22))
}
@@ -0,0 +1,114 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts ===
export {};
// reparse call as invalid await should error
await (1,);
>await (1,) : any
>(1,) : any
>1, : any
>1 : 1
> : any
await <number, string>(1);
>await <number, string>(1) : boolean
>await <number : number
><number : number
> : any
>string>(1) : boolean
>string : any
>(1) : 1
>1 : 1
// reparse tagged template as invalid await should error
await <number, string> ``;
>await <number, string> `` : boolean
>await <number : number
><number : number
> : any
>string> `` : boolean
>string : any
>`` : ""
// reparse class extends clause should fail
class C extends await<string> {
>C : C
> : any
}
// await in class decorators should fail
@(await)
>(await) : any
>await : any
> : any
class C1 {}
>C1 : C1
@await(x)
> : any
class C2 {}
>C2 : C2
@await
> : any
class C3 {}
>C3 : C3
// await in member decorators should fail
class C4 {
>C4 : C4
@await
> : any
["foo"]() {}
>["foo"] : () => void
>"foo" : "foo"
}
class C5 {
>C5 : C5
@await(1)
> : any
["foo"]() {}
>["foo"] : () => void
>"foo" : "foo"
}
class C6 {
>C6 : C6
@(await)
>(await) : any
>await : any
> : any
["foo"]() {}
>["foo"] : () => void
>"foo" : "foo"
}
// await in parameter decorators should fail
class C7 {
>C7 : C7
method1(@await [x]) {}
>method1 : ([x]: [any]) => void
> : any
>x : any
method2(@await(1) [x]) {}
>method2 : ([x]: [any]) => void
> : any
>x : any
method3(@(await) [x]) {}
>method3 : ([x]: [any]) => void
>(await) : any
>await : any
> : any
>x : any
}
@@ -0,0 +1,13 @@
tests/cases/conformance/externalModules/index.ts(2,19): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/index.ts (1 errors) ====
// await disallowed in alias of named import
import { await as await } from "./other";
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
declare const _await: any;
export { _await as await };
@@ -0,0 +1,15 @@
//// [tests/cases/conformance/externalModules/topLevelAwaitErrors.10.ts] ////
//// [index.ts]
// await disallowed in alias of named import
import { await as await } from "./other";
//// [other.ts]
declare const _await: any;
export { _await as await };
//// [other.js]
export { _await as await };
//// [index.js]
export {};
@@ -0,0 +1,14 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in alias of named import
import { await as await } from "./other";
>await : Symbol(await, Decl(other.ts, 1, 8))
>await : Symbol(await, Decl(index.ts, 1, 8))
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 13))
>await : Symbol(await, Decl(other.ts, 1, 8))
@@ -0,0 +1,14 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in alias of named import
import { await as await } from "./other";
>await : any
>await : any
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : any
export { _await as await };
>_await : any
>await : any
@@ -0,0 +1,14 @@
tests/cases/conformance/externalModules/index.ts(3,8): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/index.ts (1 errors) ====
// await disallowed in import=
declare var require: any;
import await = require("./other");
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
declare const _await: any;
export { _await as await };
@@ -0,0 +1,32 @@
//// [tests/cases/conformance/externalModules/topLevelAwaitErrors.11.ts] ////
//// [index.ts]
// await disallowed in import=
declare var require: any;
import await = require("./other");
//// [other.ts]
declare const _await: any;
export { _await as await };
//// [other.js]
System.register([], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
}
};
});
//// [index.js]
System.register([], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
}
};
});
@@ -0,0 +1,16 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in import=
declare var require: any;
>require : Symbol(require, Decl(index.ts, 1, 11))
import await = require("./other");
>await : Symbol(await, Decl(index.ts, 1, 25))
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 13))
>await : Symbol(await, Decl(other.ts, 1, 8))
@@ -0,0 +1,16 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in import=
declare var require: any;
>require : any
import await = require("./other");
>await : typeof await
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : any
export { _await as await };
>_await : any
>await : any
@@ -0,0 +1,12 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.12.ts(5,8): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.12.ts (1 errors) ====
export {};
declare namespace foo { const await: any; }
// await disallowed in import=namespace when in a module
import await = foo.await;
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
@@ -0,0 +1,10 @@
//// [topLevelAwaitErrors.12.ts]
export {};
declare namespace foo { const await: any; }
// await disallowed in import=namespace when in a module
import await = foo.await;
//// [topLevelAwaitErrors.12.js]
export {};
@@ -0,0 +1,12 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.12.ts ===
export {};
declare namespace foo { const await: any; }
>foo : Symbol(foo, Decl(topLevelAwaitErrors.12.ts, 0, 10))
>await : Symbol(await, Decl(topLevelAwaitErrors.12.ts, 1, 29))
// await disallowed in import=namespace when in a module
import await = foo.await;
>await : Symbol(await, Decl(topLevelAwaitErrors.12.ts, 1, 43))
>foo : Symbol(foo, Decl(topLevelAwaitErrors.12.ts, 0, 10))
>await : Symbol(await, Decl(topLevelAwaitErrors.12.ts, 1, 29))
@@ -0,0 +1,12 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.12.ts ===
export {};
declare namespace foo { const await: any; }
>foo : typeof foo
>await : any
// await disallowed in import=namespace when in a module
import await = foo.await;
>await : any
>foo : typeof foo
>await : any
@@ -0,0 +1,11 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.2.ts(4,5): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.2.ts (1 errors) ====
export {};
// reparse variable name as await should fail
var await = 1;
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
@@ -0,0 +1,11 @@
//// [topLevelAwaitErrors.2.ts]
export {};
// reparse variable name as await should fail
var await = 1;
//// [topLevelAwaitErrors.2.js]
// reparse variable name as await should fail
var await = 1;
export {};
@@ -0,0 +1,7 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.2.ts ===
export {};
// reparse variable name as await should fail
var await = 1;
>await : Symbol(await, Decl(topLevelAwaitErrors.2.ts, 3, 3))
@@ -0,0 +1,8 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.2.ts ===
export {};
// reparse variable name as await should fail
var await = 1;
>await : number
>1 : 1
@@ -0,0 +1,11 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.3.ts(4,6): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.3.ts (1 errors) ====
export {};
// reparse binding pattern as await should fail
var {await} = {await:1};
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
@@ -0,0 +1,11 @@
//// [topLevelAwaitErrors.3.ts]
export {};
// reparse binding pattern as await should fail
var {await} = {await:1};
//// [topLevelAwaitErrors.3.js]
// reparse binding pattern as await should fail
var { await } = { await: 1 };
export {};
@@ -0,0 +1,8 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.3.ts ===
export {};
// reparse binding pattern as await should fail
var {await} = {await:1};
>await : Symbol(await, Decl(topLevelAwaitErrors.3.ts, 3, 5))
>await : Symbol(await, Decl(topLevelAwaitErrors.3.ts, 3, 15))
@@ -0,0 +1,10 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.3.ts ===
export {};
// reparse binding pattern as await should fail
var {await} = {await:1};
>await : number
>{await:1} : { await: number; }
>await : number
>1 : 1
@@ -0,0 +1,11 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.4.ts(4,6): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.4.ts (1 errors) ====
export {};
// reparse binding pattern as await should fail
var [await] = [1];
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
@@ -0,0 +1,11 @@
//// [topLevelAwaitErrors.4.ts]
export {};
// reparse binding pattern as await should fail
var [await] = [1];
//// [topLevelAwaitErrors.4.js]
// reparse binding pattern as await should fail
var [await] = [1];
export {};
@@ -0,0 +1,7 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.4.ts ===
export {};
// reparse binding pattern as await should fail
var [await] = [1];
>await : Symbol(await, Decl(topLevelAwaitErrors.4.ts, 3, 5))
@@ -0,0 +1,9 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.4.ts ===
export {};
// reparse binding pattern as await should fail
var [await] = [1];
>await : number
>[1] : [number]
>1 : 1
@@ -0,0 +1,10 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.5.ts(2,14): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.5.ts (1 errors) ====
// await in exported class name should fail
export class await {
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
}
@@ -0,0 +1,10 @@
//// [topLevelAwaitErrors.5.ts]
// await in exported class name should fail
export class await {
}
//// [topLevelAwaitErrors.5.js]
// await in exported class name should fail
export class await {
}
@@ -0,0 +1,6 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.5.ts ===
// await in exported class name should fail
export class await {
>await : Symbol(await, Decl(topLevelAwaitErrors.5.ts, 0, 0))
}
@@ -0,0 +1,6 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.5.ts ===
// await in exported class name should fail
export class await {
>await : await
}
@@ -0,0 +1,10 @@
tests/cases/conformance/externalModules/topLevelAwaitErrors.6.ts(2,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/topLevelAwaitErrors.6.ts (1 errors) ====
// await in exported function name should fail
export function await() {
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
}
@@ -0,0 +1,10 @@
//// [topLevelAwaitErrors.6.ts]
// await in exported function name should fail
export function await() {
}
//// [topLevelAwaitErrors.6.js]
// await in exported function name should fail
export function await() {
}
@@ -0,0 +1,6 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.6.ts ===
// await in exported function name should fail
export function await() {
>await : Symbol(await, Decl(topLevelAwaitErrors.6.ts, 0, 0))
}
@@ -0,0 +1,6 @@
=== tests/cases/conformance/externalModules/topLevelAwaitErrors.6.ts ===
// await in exported function name should fail
export function await() {
>await : () => void
}
@@ -0,0 +1,12 @@
tests/cases/conformance/externalModules/index.ts(2,13): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/index.ts (1 errors) ====
// await disallowed in namespace import
import * as await from "./other";
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
declare const _await: any;
export { _await as await };
@@ -0,0 +1,14 @@
//// [tests/cases/conformance/externalModules/topLevelAwaitErrors.7.ts] ////
//// [index.ts]
// await disallowed in namespace import
import * as await from "./other";
//// [other.ts]
declare const _await: any;
export { _await as await };
//// [other.js]
export { _await as await };
//// [index.js]
export {};
@@ -0,0 +1,13 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in namespace import
import * as await from "./other";
>await : Symbol(await, Decl(index.ts, 1, 6))
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 13))
>await : Symbol(await, Decl(other.ts, 1, 8))
@@ -0,0 +1,13 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in namespace import
import * as await from "./other";
>await : typeof await
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : any
export { _await as await };
>_await : any
>await : any
@@ -0,0 +1,13 @@
tests/cases/conformance/externalModules/index.ts(2,8): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/index.ts (1 errors) ====
// await disallowed in default import
import await from "./other";
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
declare const _await: any;
export default _await;
@@ -0,0 +1,15 @@
//// [tests/cases/conformance/externalModules/topLevelAwaitErrors.8.ts] ////
//// [index.ts]
// await disallowed in default import
import await from "./other";
//// [other.ts]
declare const _await: any;
export default _await;
//// [other.js]
export default _await;
//// [index.js]
export {};
@@ -0,0 +1,12 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in default import
import await from "./other";
>await : Symbol(await, Decl(index.ts, 1, 6))
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
export default _await;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
@@ -0,0 +1,12 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in default import
import await from "./other";
>await : any
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : any
export default _await;
>_await : any
@@ -0,0 +1,13 @@
tests/cases/conformance/externalModules/index.ts(2,10): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/index.ts (1 errors) ====
// await disallowed in un-alised named import
import { await } from "./other";
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
==== tests/cases/conformance/externalModules/other.ts (0 errors) ====
declare const _await: any;
export { _await as await };
@@ -0,0 +1,15 @@
//// [tests/cases/conformance/externalModules/topLevelAwaitErrors.9.ts] ////
//// [index.ts]
// await disallowed in un-alised named import
import { await } from "./other";
//// [other.ts]
declare const _await: any;
export { _await as await };
//// [other.js]
export { _await as await };
//// [index.js]
export {};
@@ -0,0 +1,13 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in un-alised named import
import { await } from "./other";
>await : Symbol(await, Decl(index.ts, 1, 8))
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : Symbol(_await, Decl(other.ts, 0, 13))
export { _await as await };
>_await : Symbol(_await, Decl(other.ts, 0, 13))
>await : Symbol(await, Decl(other.ts, 1, 8))
@@ -0,0 +1,13 @@
=== tests/cases/conformance/externalModules/index.ts ===
// await disallowed in un-alised named import
import { await } from "./other";
>await : any
=== tests/cases/conformance/externalModules/other.ts ===
declare const _await: any;
>_await : any
export { _await as await };
>_await : any
>await : any
@@ -0,0 +1,62 @@
// @target: es2015,es2017
// @module: esnext,system
// @experimentalDecorators: true
// @noEmitHelpers: true
// @filename: index.ts
export const x = 1;
await x;
// reparse element access as await
await [x];
await [x, x];
// reparse call as await
declare function f(): number;
await (x);
await (f(), x);
await <number>(x);
await <number>(f(), x);
// reparse tagged template as await
await ``;
await <string> ``;
// member names should be ok
class C1 {
await() {}
}
class C2 {
get await() { return 1; }
set await(value) { }
}
class C3 {
await = 1;
}
({
await() {}
});
({
get await() { return 1 },
set await(value) { }
});
({
await: 1
});
// property access name should be ok
C1.prototype.await;
// await in decorators
declare const dec: any;
@(await dec)
class C {
}
// await allowed in aliased import
import { await as _await } from "./other";
// @filename: other.ts
const _await = 1;
// await allowed in aliased export
export { _await as await };
@@ -0,0 +1,7 @@
// @target: esnext
// @module: esnext
declare namespace foo { const await: any; }
// await allowed in import=namespace when not a module
import await = foo.await;
@@ -0,0 +1,8 @@
// @target: esnext
// @module: esnext
// @filename: index.d.ts
// await keyword allowed as identifier in a declaration file
export {};
declare const await: any;
declare class C extends await {}
@@ -1,4 +0,0 @@
// @target: es2015,es2017
// @module: esnext,system
export const x = 1;
await x;
@@ -0,0 +1,48 @@
// @target: esnext
// @module: esnext
// @experimentalDecorators: true
// @noEmitHelpers: true
export {};
// reparse call as invalid await should error
await (1,);
await <number, string>(1);
// reparse tagged template as invalid await should error
await <number, string> ``;
// reparse class extends clause should fail
class C extends await<string> {
}
// await in class decorators should fail
@(await)
class C1 {}
@await(x)
class C2 {}
@await
class C3 {}
// await in member decorators should fail
class C4 {
@await
["foo"]() {}
}
class C5 {
@await(1)
["foo"]() {}
}
class C6 {
@(await)
["foo"]() {}
}
// await in parameter decorators should fail
class C7 {
method1(@await [x]) {}
method2(@await(1) [x]) {}
method3(@(await) [x]) {}
}
@@ -0,0 +1,10 @@
// @target: esnext
// @module: esnext
// @filename: index.ts
// await disallowed in alias of named import
import { await as await } from "./other";
// @filename: other.ts
declare const _await: any;
export { _await as await };
@@ -0,0 +1,11 @@
// @target: esnext
// @module: system
// @filename: index.ts
// await disallowed in import=
declare var require: any;
import await = require("./other");
// @filename: other.ts
declare const _await: any;
export { _await as await };
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff. Show more