diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7549759138967..ad35852c22865 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2109,20 +2109,39 @@ namespace ts { } // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized - // check for reserved words used as identifiers in strict mode code. - function checkStrictModeIdentifier(node: Identifier) { - if (inStrictMode && - node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord && - node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord && - !isIdentifierName(node) && + // check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in + // [Yield] or [Await] contexts, respectively. + function checkContextualIdentifier(node: Identifier) { + // Report error only if there are no parse errors in file + if (!file.parseDiagnostics.length && !(node.flags & NodeFlags.Ambient) && - !(node.flags & NodeFlags.JSDoc)) { + !(node.flags & NodeFlags.JSDoc) && + !isIdentifierName(node)) { - // Report error only if there are no parse errors in file - if (!file.parseDiagnostics.length) { + // strict mode identifiers + if (inStrictMode && + node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord && + node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), declarationNameToString(node))); } + else if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) { + if (isExternalModule(file) && isInTopLevelContext(node)) { + file.bindDiagnostics.push(createDiagnosticForNode(node, + Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, + declarationNameToString(node))); + } + else if (node.flags & NodeFlags.AwaitContext) { + file.bindDiagnostics.push(createDiagnosticForNode(node, + Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, + declarationNameToString(node))); + } + } + else if (node.originalKeywordKind === SyntaxKind.YieldKeyword && node.flags & NodeFlags.YieldContext) { + file.bindDiagnostics.push(createDiagnosticForNode(node, + Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, + declarationNameToString(node))); + } } } @@ -2423,7 +2442,7 @@ namespace ts { if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) { node.flowNode = currentFlow; } - return checkStrictModeIdentifier(node); + return checkContextualIdentifier(node); case SyntaxKind.SuperKeyword: node.flowNode = currentFlow; break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 595a64777c605..5f6f42fdf7f27 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28255,11 +28255,6 @@ namespace ts { return undefinedWideningType; } - function isInTopLevelContext(node: Node) { - const container = getThisContainer(node, /*includeArrowFunctions*/ true); - return isSourceFile(container); - } - function checkAwaitExpression(node: AwaitExpression): Type { // Grammar checking if (produceDiagnostics) { @@ -34861,7 +34856,6 @@ namespace ts { } function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) { - checkGrammarAwaitIdentifier(node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name!); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name!); checkAliasSymbol(node); @@ -37627,22 +37621,11 @@ 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) || - (isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) || (isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node)); @@ -37650,8 +37633,7 @@ namespace ts { function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { const file = getSourceFileOfNode(node); - return (isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) || - checkGrammarClassDeclarationHeritageClauses(node) || + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); } @@ -38294,10 +38276,6 @@ namespace ts { } } - 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); @@ -38361,9 +38339,6 @@ 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); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2cf85a563f5b2..ff50656a68ca5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -710,33 +710,6 @@ 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; @@ -805,6 +778,9 @@ namespace ts { // descent parsing and unwinding. let contextFlags: NodeFlags; + // Indicates whether we are currently parsing top-level statements. + let topLevel = true; + // Whether or not we've had a parse error since creating the last AST node. If we have // encountered an error, it will be stored on the next AST node we create. Parse errors // can be broken down into three categories: @@ -958,6 +934,7 @@ namespace ts { identifierCount = 0; nodeCount = 0; sourceFlags = 0; + topLevel = true; switch (scriptKind) { case ScriptKind.JS: @@ -998,6 +975,7 @@ namespace ts { parsingContext = 0; identifiers = undefined!; notParenthesizedArrow = undefined!; + topLevel = true; } function parseSourceFileWorker(languageVersion: ScriptTarget, setParentNodes: boolean, scriptKind: ScriptKind): SourceFile { @@ -1058,130 +1036,112 @@ namespace ts { } function reparseTopLevelAwait(sourceFile: SourceFile) { - return visitEachChild(sourceFile, visitor, reparseContext); - - function visitor(node: Node): VisitResult { - 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(node: T, parse: () => T): T | Expression; - function reparse(node: T | undefined, parse: () => T): T | Expression | undefined; - function reparse(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(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); - } + const savedSyntaxCursor = syntaxCursor; + const baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile); + syntaxCursor = { currentNode }; - function reparseReturnStatement(node: ReturnStatement) { - return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node); - } + const statements: Statement[] = []; + const savedParseDiagnostics = parseDiagnostics; - 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); - } + parseDiagnostics = []; - function reparseSwitchStatement(node: SwitchStatement) { - return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node); - } + let pos = 0; + let start = findNextStatementWithAwait(sourceFile.statements, 0); + while (start !== -1) { + // append all statements between pos and start + const prevStatement = sourceFile.statements[pos]; + const nextStatement = sourceFile.statements[start]; + addRange(statements, sourceFile.statements, pos, start); + pos = findNextStatementWithoutAwait(sourceFile.statements, start); + + // append all diagnostics associated with the copied range + const diagnosticStart = findIndex(savedParseDiagnostics, diagnostic => diagnostic.start >= prevStatement.pos); + const diagnosticEnd = diagnosticStart >= 0 ? findIndex(savedParseDiagnostics, diagnostic => diagnostic.start >= nextStatement.pos, diagnosticStart) : -1; + if (diagnosticStart >= 0) { + addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined); + } + + // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. + speculationHelper(() => { + const savedContextFlags = contextFlags; + contextFlags |= NodeFlags.AwaitContext; + scanner.setTextPos(nextStatement.pos); + nextToken(); - function reparseWithStatement(node: WithStatement) { - return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node); - } + while (token() !== SyntaxKind.EndOfFileToken) { + const startPos = scanner.getStartPos(); + const statement = parseListElement(ParsingContext.SourceElements, parseStatement); + statements.push(statement); + if (startPos === scanner.getStartPos()) { + nextToken(); + } - function reparseDoStatement(node: DoStatement) { - return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node); - } + if (pos >= 0) { + const nonAwaitStatement = sourceFile.statements[pos]; + if (statement.end === nonAwaitStatement.pos) { + // done reparsing this section + break; + } + if (statement.end > nonAwaitStatement.pos) { + // we ate into the next statement, so we must reparse it. + pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1); + } + } + } - function reparseWhileStatement(node: WhileStatement) { - return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node); - } + contextFlags = savedContextFlags; + }, SpeculationKind.Reparse); - 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); + // find the next statement containing an `await` + start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; } - function reparseForInStatement(node: ForInStatement) { - return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node); - } + // append all statements between pos and the end of the list + if (pos >= 0) { + const prevStatement = sourceFile.statements[pos]; + addRange(statements, sourceFile.statements, pos); - 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); + // append all diagnostics associated with the copied range + const diagnosticStart = findIndex(savedParseDiagnostics, diagnostic => diagnostic.start >= prevStatement.pos); + if (diagnosticStart >= 0) { + addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart); + } } - function reparseExportAssignment(node: ExportAssignment) { - return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node); - } + syntaxCursor = savedSyntaxCursor; + return factory.updateSourceFile(sourceFile, setTextRange(factory.createNodeArray(statements), sourceFile.statements)); - function reparseExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { - return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node); + function containsPossibleTopLevelAwait(node: Node) { + return !(node.flags & NodeFlags.AwaitContext) + && !!(node.transformFlags & TransformFlags.ContainsPossibleTopLevelAwait); } - function reparseDecorator(node: Decorator) { - return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node); + function findNextStatementWithAwait(statements: NodeArray, start: number) { + for (let i = start; i < statements.length; i++) { + if (containsPossibleTopLevelAwait(statements[i])) { + return i; + } + } + return -1; } - function reparseComputedPropertyName(node: ComputedPropertyName) { - return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node); + function findNextStatementWithoutAwait(statements: NodeArray, start: number) { + for (let i = start; i < statements.length; i++) { + if (!containsPossibleTopLevelAwait(statements[i])) { + return i; + } + } + return -1; } - function reparseVariableDeclaration(node: VariableDeclaration) { - return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node); + function currentNode(position: number) { + const node = baseSyntaxCursor.currentNode(position); + if (topLevel && node && containsPossibleTopLevelAwait(node)) { + node.intersectsChange = true; + } + return 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) { @@ -1487,6 +1447,13 @@ namespace ts { return speculationHelper(callback, SpeculationKind.TryParse); } + function isBindingIdentifier(): boolean { + if (token() === SyntaxKind.Identifier) { + return true; + } + return token() > SyntaxKind.LastReservedWord; + } + // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier(): boolean { if (token() === SyntaxKind.Identifier) { @@ -1693,6 +1660,10 @@ namespace ts { return createMissingNode(SyntaxKind.Identifier, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } + function parseBindingIdentifier(privateIdentifierDiagnosticMessage?: DiagnosticMessage) { + return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); + } + function parseIdentifier(diagnosticMessage?: DiagnosticMessage, privateIdentifierDiagnosticMessage?: DiagnosticMessage): Identifier { return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage); } @@ -1888,9 +1859,9 @@ namespace ts { return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } case ParsingContext.VariableDeclarations: - return isIdentifierOrPrivateIdentifierOrPattern(); + return isBindingIdentifierOrPrivateIdentifierOrPattern(); case ParsingContext.ArrayBindingElements: - return token() === SyntaxKind.CommaToken || token() === SyntaxKind.DotDotDotToken || isIdentifierOrPrivateIdentifierOrPattern(); + return token() === SyntaxKind.CommaToken || token() === SyntaxKind.DotDotDotToken || isBindingIdentifierOrPrivateIdentifierOrPattern(); case ParsingContext.TypeParameters: return isIdentifier(); case ParsingContext.ArrayLiteralMembers: @@ -2893,7 +2864,7 @@ namespace ts { function isStartOfParameter(isJSDocParameter: boolean): boolean { return token() === SyntaxKind.DotDotDotToken || - isIdentifierOrPrivateIdentifierOrPattern() || + isBindingIdentifierOrPrivateIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); @@ -2917,7 +2888,15 @@ namespace ts { return name; } + function parseParameterInOuterAwaitContext() { + return parseParameterWorker(/*inOuterAwaitContext*/ true); + } + function parseParameter(): ParameterDeclaration { + return parseParameterWorker(/*inOuterAwaitContext*/ false); + } + + function parseParameterWorker(inOuterAwaitContext: boolean): ParameterDeclaration { const pos = getNodePos(); const hasJSDoc = hasPrecedingJSDocComment(); if (token() === SyntaxKind.ThisKeyword) { @@ -2935,12 +2914,17 @@ namespace ts { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] - let modifiers; - return withJSDoc( + + // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. + const decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); + const savedTopLevel = topLevel; + topLevel = false; + const modifiers = parseModifiers(); + const node = withJSDoc( finishNode( factory.createParameterDeclaration( - parseDecorators(), - modifiers = parseModifiers(), + decorators, + modifiers, parseOptionalToken(SyntaxKind.DotDotDotToken), parseNameOfParameter(modifiers), parseOptionalToken(SyntaxKind.QuestionToken), @@ -2951,6 +2935,8 @@ namespace ts { ), hasJSDoc ); + topLevel = savedTopLevel; + return node; } function parseReturnType(returnToken: SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode; @@ -3000,7 +2986,7 @@ namespace ts { const parameters = flags & SignatureFlags.JSDoc ? parseDelimitedList(ParsingContext.JSDocParameters, parseJSDocParameter) : - parseDelimitedList(ParsingContext.Parameters, parseParameter); + parseDelimitedList(ParsingContext.Parameters, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -4268,9 +4254,13 @@ namespace ts { return parseFunctionBlock(SignatureFlags.IgnoreMissingOpenBrace | (isAsync ? SignatureFlags.Await : SignatureFlags.None)); } - return isAsync + const savedTopLevel = topLevel; + topLevel = false; + const node = isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + topLevel = savedTopLevel; + return node; } function parseConditionalExpressionRest(leftOperand: Expression, pos: number): Expression { @@ -5390,10 +5380,10 @@ namespace ts { const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; const isAsync = some(modifiers, isAsyncModifier) ? SignatureFlags.Await : SignatureFlags.None; const name = - isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : - isGenerator ? doInYieldContext(parseOptionalIdentifier) : - isAsync ? doInAwaitContext(parseOptionalIdentifier) : - parseOptionalIdentifier(); + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : + isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : + isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : + parseOptionalBindingIdentifier(); const typeParameters = parseTypeParameters(); const parameters = parseParameters(isGenerator | isAsync); @@ -5408,8 +5398,8 @@ namespace ts { return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseOptionalIdentifier(): Identifier | undefined { - return isIdentifier() ? parseIdentifier() : undefined; + function parseOptionalBindingIdentifier(): Identifier | undefined { + return isBindingIdentifier() ? parseBindingIdentifier() : undefined; } function parseNewExpressionOrNewDotTarget(): NewExpression | MetaProperty { @@ -5476,6 +5466,9 @@ namespace ts { const savedAwaitContext = inAwaitContext(); setAwaitContext(!!(flags & SignatureFlags.Await)); + const savedTopLevel = topLevel; + topLevel = false; + // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. const saveDecoratorContext = inDecoratorContext(); @@ -5489,6 +5482,7 @@ namespace ts { setDecoratorContext(/*val*/ true); } + topLevel = savedTopLevel; setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -6108,7 +6102,7 @@ namespace ts { function parseObjectBindingElement(): BindingElement { const pos = getNodePos(); const dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - const tokenIsIdentifier = isIdentifier(); + const tokenIsIdentifier = isBindingIdentifier(); let propertyName: PropertyName | undefined = parsePropertyName(); let name: BindingName; if (tokenIsIdentifier && token() !== SyntaxKind.ColonToken) { @@ -6139,11 +6133,11 @@ namespace ts { return finishNode(factory.createArrayBindingPattern(elements), pos); } - function isIdentifierOrPrivateIdentifierOrPattern() { + function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.PrivateIdentifier - || isIdentifier(); + || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage?: DiagnosticMessage): Identifier | BindingPattern { @@ -6153,7 +6147,7 @@ namespace ts { if (token() === SyntaxKind.OpenBraceToken) { return parseObjectBindingPattern(); } - return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); + return parseBindingIdentifier(privateIdentifierDiagnosticMessage); } function parseVariableDeclarationAllowExclamation() { @@ -6238,7 +6232,7 @@ namespace ts { 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 name = modifierFlags & ModifierFlags.Default ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; const isAsync = modifierFlags & ModifierFlags.Async ? SignatureFlags.Await : SignatureFlags.None; const typeParameters = parseTypeParameters(); @@ -6429,12 +6423,25 @@ namespace ts { return false; } + function parseDecoratorExpression() { + if (inAwaitContext() && token() === SyntaxKind.AwaitKeyword) { + // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails + // This simply parses the missing identifier and moves on. + const pos = getNodePos(); + const awaitExpression = parseIdentifier(Diagnostics.Expression_expected); + nextToken(); + const memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true); + return parseCallExpressionRest(pos, memberExpression); + } + return parseLeftHandSideExpressionOrHigher(); + } + function tryParseDecorator(): Decorator | undefined { const pos = getNodePos(); if (!parseOptional(SyntaxKind.AtToken)) { return undefined; } - const expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); + const expression = doInDecoratorContext(parseDecoratorExpression); return finishNode(factory.createDecorator(expression), pos); } @@ -6593,8 +6600,8 @@ namespace ts { // - class expression with omitted name, 'implements' starts heritage clause // - class with name 'implements' // 'isImplementsClause' helps to disambiguate between these two cases - return isIdentifier() && !isImplementsClause() - ? parseIdentifier() + return isBindingIdentifier() && !isImplementsClause() + ? createIdentifier(isBindingIdentifier()) : undefined; } @@ -8538,7 +8545,7 @@ namespace ts { currentNode(position: number): IncrementalNode; } - function createSyntaxCursor(sourceFile: SourceFile): SyntaxCursor { + export function createSyntaxCursor(sourceFile: SourceFile): SyntaxCursor { let currentArray: NodeArray = sourceFile.statements; let currentArrayIndex = 0; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b147e79348733..e50dbd7224236 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1525,6 +1525,15 @@ namespace ts { } } + export function isInTopLevelContext(node: Node) { + // The name of a class or function declaration is a BindingIdentifier in its surrounding scope. + if (isIdentifier(node) && (isClassDeclaration(node.parent) || isFunctionDeclaration(node.parent)) && node.parent.name === node) { + node = node.parent; + } + const container = getThisContainer(node, /*includeArrowFunctions*/ true); + return isSourceFile(container); + } + export function getNewTargetContainer(node: Node) { const container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { @@ -2786,7 +2795,7 @@ namespace ts { // Return true if the given identifier is classified as an IdentifierName export function isIdentifierName(node: Identifier): boolean { - let parent = node.parent; + const parent = node.parent; switch (parent.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: @@ -2801,13 +2810,7 @@ namespace ts { return (parent).name === node; case SyntaxKind.QualifiedName: // Name on right hand side of dot in a type query or type reference - if ((parent).right === node) { - while (parent.kind === SyntaxKind.QualifiedName) { - parent = parent.parent; - } - return parent.kind === SyntaxKind.TypeQuery || parent.kind === SyntaxKind.TypeReference; - } - return false; + return (parent).right === node; case SyntaxKind.BindingElement: case SyntaxKind.ImportSpecifier: // Property name in binding element or import specifier diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index b975b1d0e2bde..b2ec665ce8962 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -321,6 +321,8 @@ namespace ts { * @param context A lexical environment context for the visitor. */ export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + /* @internal */ + export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T; // eslint-disable-line @typescript-eslint/unified-signatures /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 6efd10dce099f..9f1e12a48ac65 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,20 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (2 errors) ==== function * foo(a = yield => yield) { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. ~~ !!! error TS1005: ',' expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - ~ -!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index aca7c00e58c0a..73eb9bedcdbb8 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,7 +3,5 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function* foo(a = yield) { } -yield; -{ +function* foo(a = yield, yield) { } diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.symbols b/tests/baselines/reference/FunctionDeclaration10_es6.symbols index 2b1ccb2a6368a..3b6631df8b8d3 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.symbols +++ b/tests/baselines/reference/FunctionDeclaration10_es6.symbols @@ -2,4 +2,5 @@ function * foo(a = yield => yield) { >foo : Symbol(foo, Decl(FunctionDeclaration10_es6.ts, 0, 0)) >a : Symbol(a, Decl(FunctionDeclaration10_es6.ts, 0, 15)) +>yield : Symbol(yield, Decl(FunctionDeclaration10_es6.ts, 0, 27)) } diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.types b/tests/baselines/reference/FunctionDeclaration10_es6.types index 2bd25f5a63084..e30b5be2d76ac 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.types +++ b/tests/baselines/reference/FunctionDeclaration10_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts === function * foo(a = yield => yield) { ->foo : (a?: any) => any +>foo : (a: any, yield: any) => Generator >a : any >yield : any >yield : any diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt index 425536f8781d5..aa3f0f7e39689 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt @@ -1,13 +1,7 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1005: '(' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: ',' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,28): error TS1005: '=>' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts (1 errors) ==== var v = function * yield() { } ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1005: '=>' expected. \ No newline at end of file +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.js b/tests/baselines/reference/FunctionDeclaration12_es6.js index d2f490ef5e8d5..c284e42620dd8 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.js +++ b/tests/baselines/reference/FunctionDeclaration12_es6.js @@ -2,5 +2,4 @@ var v = function * yield() { } //// [FunctionDeclaration12_es6.js] -var v = function* () { }, yield; -() => { }; +var v = function* yield() { }; diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.symbols b/tests/baselines/reference/FunctionDeclaration12_es6.symbols index d2bdccc179e42..2bb80a2cd5d89 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.symbols +++ b/tests/baselines/reference/FunctionDeclaration12_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts === var v = function * yield() { } >v : Symbol(v, Decl(FunctionDeclaration12_es6.ts, 0, 3)) ->yield : Symbol(yield, Decl(FunctionDeclaration12_es6.ts, 0, 18)) +>yield : Symbol(yield, Decl(FunctionDeclaration12_es6.ts, 0, 7)) diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.types b/tests/baselines/reference/FunctionDeclaration12_es6.types index 336bde7a9472e..307b391bdb97c 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.types +++ b/tests/baselines/reference/FunctionDeclaration12_es6.types @@ -1,7 +1,6 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts === var v = function * yield() { } ->v : () => any ->function * : () => any ->yield : any ->() { } : () => void +>v : () => Generator +>function * yield() { } : () => Generator +>yield : () => Generator diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt index c68a6cb205791..1c13fcfd7d53b 100644 --- a/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt @@ -1,14 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS1138: Parameter declaration expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,19): error TS1005: ';' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (1 errors) ==== function*foo(yield) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.js b/tests/baselines/reference/FunctionDeclaration5_es6.js index 645ee976ecd96..22f1ff7030d49 100644 --- a/tests/baselines/reference/FunctionDeclaration5_es6.js +++ b/tests/baselines/reference/FunctionDeclaration5_es6.js @@ -3,7 +3,5 @@ function*foo(yield) { } //// [FunctionDeclaration5_es6.js] -function* foo() { } -yield; -{ +function* foo(yield) { } diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.symbols b/tests/baselines/reference/FunctionDeclaration5_es6.symbols index 67732f518e5c4..33e9f437fdf85 100644 --- a/tests/baselines/reference/FunctionDeclaration5_es6.symbols +++ b/tests/baselines/reference/FunctionDeclaration5_es6.symbols @@ -1,4 +1,5 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts === function*foo(yield) { >foo : Symbol(foo, Decl(FunctionDeclaration5_es6.ts, 0, 0)) +>yield : Symbol(yield, Decl(FunctionDeclaration5_es6.ts, 0, 13)) } diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.types b/tests/baselines/reference/FunctionDeclaration5_es6.types index 9478988e7eaa7..beaee0c50d52a 100644 --- a/tests/baselines/reference/FunctionDeclaration5_es6.types +++ b/tests/baselines/reference/FunctionDeclaration5_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts === function*foo(yield) { ->foo : () => any +>foo : (yield: any) => Generator >yield : any } diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt index ae57468b89407..670669495cbbe 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt @@ -1,24 +1,8 @@ -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,11): error TS2304: Cannot find name 'async'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,18): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,18): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts (6 errors) ==== +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts (1 errors) ==== var foo = async (await): Promise => { - ~~~~~ -!!! error TS2304: Cannot find name 'async'. ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -!!! related TS6203 /.ts/lib.es2015.promise.d.ts:150:13: 'Promise' was also declared here. - ~ -!!! error TS1005: ',' expected. - ~~ -!!! error TS1109: Expression expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js index c3ce23ad103a4..04beb16cd74d7 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -3,7 +3,5 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es2017.js] -var foo = async(await), Promise; -; -{ -} +var foo = async (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.symbols b/tests/baselines/reference/asyncArrowFunction5_es2017.symbols index af04f643524e9..b7d25bf2c3cff 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.symbols +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts === var foo = async (await): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction5_es2017.ts, 0, 3)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(asyncArrowFunction5_es2017.ts, 0, 24)) +>await : Symbol(await, Decl(asyncArrowFunction5_es2017.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.types b/tests/baselines/reference/asyncArrowFunction5_es2017.types index 95cebf9afba37..0e5eb0875594a 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.types +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.types @@ -1,10 +1,6 @@ === tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts === var foo = async (await): Promise => { ->foo : any ->async (await) : any ->async : any +>foo : (await: any) => Promise +>async (await): Promise => {} : (await: any) => Promise >await : any ->Promise : PromiseConstructor -> : void -> : any } diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt index ff87906ead394..46dae75c2cea4 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt @@ -1,24 +1,8 @@ -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,11): error TS2304: Cannot find name 'async'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,18): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,18): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts (6 errors) ==== +==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts (1 errors) ==== var foo = async (await): Promise => { - ~~~~~ -!!! error TS2304: Cannot find name 'async'. ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -!!! related TS6203 /.ts/lib.es2015.promise.d.ts:150:13: 'Promise' was also declared here. - ~ -!!! error TS1005: ',' expected. - ~~ -!!! error TS1109: Expression expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.js b/tests/baselines/reference/asyncArrowFunction5_es5.js index ac1e880155177..073331f4bbc0e 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.js +++ b/tests/baselines/reference/asyncArrowFunction5_es5.js @@ -3,7 +3,9 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es5.js] -var foo = async(await), Promise; -; -{ -} +var _this = this; +var foo = function (await) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); +}); }; diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.symbols b/tests/baselines/reference/asyncArrowFunction5_es5.symbols index b1b10c12afefc..757a80c283c3a 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.symbols +++ b/tests/baselines/reference/asyncArrowFunction5_es5.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts === var foo = async (await): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction5_es5.ts, 0, 3)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(asyncArrowFunction5_es5.ts, 0, 24)) +>await : Symbol(await, Decl(asyncArrowFunction5_es5.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.types b/tests/baselines/reference/asyncArrowFunction5_es5.types index 93385915415f3..c4bb0f1e21694 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.types +++ b/tests/baselines/reference/asyncArrowFunction5_es5.types @@ -1,10 +1,6 @@ === tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts === var foo = async (await): Promise => { ->foo : any ->async (await) : any ->async : any +>foo : (await: any) => Promise +>async (await): Promise => {} : (await: any) => Promise >await : any ->Promise : PromiseConstructor -> : void -> : any } diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt index b10782f083767..f46b7cf418d3a 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -1,24 +1,8 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,11): error TS2304: Cannot find name 'async'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,18): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,18): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts (6 errors) ==== +==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts (1 errors) ==== var foo = async (await): Promise => { - ~~~~~ -!!! error TS2304: Cannot find name 'async'. ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'. -!!! related TS6203 /.ts/lib.es2015.promise.d.ts:150:13: 'Promise' was also declared here. - ~ -!!! error TS1005: ',' expected. - ~~ -!!! error TS1109: Expression expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js index 170962c6fd514..b9b30a0e49841 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.js +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -3,7 +3,5 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es6.js] -var foo = async(await), Promise; -; -{ -} +var foo = (await) => __awaiter(this, void 0, void 0, function* () { +}); diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.symbols b/tests/baselines/reference/asyncArrowFunction5_es6.symbols index 4a5790195bda5..944fc8453ee9a 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction5_es6.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts === var foo = async (await): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction5_es6.ts, 0, 3)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(asyncArrowFunction5_es6.ts, 0, 24)) +>await : Symbol(await, Decl(asyncArrowFunction5_es6.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.types b/tests/baselines/reference/asyncArrowFunction5_es6.types index 1fffb0b1dbd59..bc38b89b6ad74 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.types +++ b/tests/baselines/reference/asyncArrowFunction5_es6.types @@ -1,10 +1,6 @@ === tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts === var foo = async (await): Promise => { ->foo : any ->async (await) : any ->async : any +>foo : (await: any) => Promise +>async (await): Promise => {} : (await: any) => Promise >await : any ->Promise : PromiseConstructor -> : void -> : any } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt index 12f9974484bbc..c6877cc6b6a93 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -1,33 +1,11 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,30): error TS1109: Expression expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,41): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,49): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (9 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (2 errors) ==== async function foo(a = await => await): Promise { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. ~~ !!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js index f8a22204311e5..b27f4aedb6685 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -3,6 +3,5 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es2017.js] -async function foo(a = await ) { } -await; -Promise < void > {}; +async function foo(a = await , await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols index de526b968ef74..0705621581feb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols @@ -2,5 +2,6 @@ async function foo(a = await => await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es2017.ts, 0, 0)) >a : Symbol(a, Decl(asyncFunctionDeclaration10_es2017.ts, 0, 19)) +>await : Symbol(await, Decl(asyncFunctionDeclaration10_es2017.ts, 0, 31)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types index 906a0966c0a0f..30fdfa6456fc1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types @@ -1,14 +1,8 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts === async function foo(a = await => await): Promise { ->foo : (a?: any) => any +>foo : (a: any, await: any) => Promise >a : any >await : any > : any >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt index 155119784ba9e..93e3e75ad47fb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt @@ -1,33 +1,11 @@ -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,30): error TS1109: Expression expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,38): error TS1005: ';' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,39): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,41): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,49): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (9 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (2 errors) ==== async function foo(a = await => await): Promise { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. ~~ !!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js index 758bdab5dc902..e42e761c6984e 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js @@ -3,11 +3,11 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es5.js] -function foo(a) { +function foo(a, await) { if (a === void 0) { a = yield ; } - return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/]; - }); }); + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); } -await; -Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols index cd989f81bce7f..909bed0ea52b1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols @@ -2,5 +2,6 @@ async function foo(a = await => await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es5.ts, 0, 0)) >a : Symbol(a, Decl(asyncFunctionDeclaration10_es5.ts, 0, 19)) +>await : Symbol(await, Decl(asyncFunctionDeclaration10_es5.ts, 0, 31)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.types b/tests/baselines/reference/asyncFunctionDeclaration10_es5.types index 70a16d0fc52ea..d29b96391e4cf 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.types +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.types @@ -1,14 +1,8 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts === async function foo(a = await => await): Promise { ->foo : (a?: any) => any +>foo : (a: any, await: any) => Promise >a : any >await : any > : any >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt index 7f5266f931e30..09cbc3a7a2690 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -1,33 +1,11 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,41): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,49): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (9 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (2 errors) ==== async function foo(a = await => await): Promise { - ~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. ~~ !!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 1f175035bf085..c5fe16ea05e20 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,8 +3,7 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] -function foo(a = yield ) { - return __awaiter(this, void 0, void 0, function* () { }); +function foo(a = yield , await) { + return __awaiter(this, void 0, void 0, function* () { + }); } -await; -Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols index f1d1994e2690e..2c78cb0e0ddce 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -2,5 +2,6 @@ async function foo(a = await => await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es6.ts, 0, 0)) >a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) +>await : Symbol(await, Decl(asyncFunctionDeclaration10_es6.ts, 0, 31)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types index f5d5ae89afd6d..fbf97067f01a8 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types @@ -1,14 +1,8 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === async function foo(a = await => await): Promise { ->foo : (a?: any) => any +>foo : (a: any, await: any) => Promise >a : any >await : any > : any >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt index 37e2c3f847f18..100589c3a5491 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt @@ -1,16 +1,7 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,47): error TS1005: '=>' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts (4 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts (1 errors) ==== var v = async function await(): Promise { } ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. - ~ -!!! error TS1005: '=>' expected. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 2ed6cf3191f10..03401f2464e43 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,5 +2,4 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = async function () { }, await; -() => { }; +var v = async function await() { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols index a6a37aa6004ed..d8a9d115a4f7d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts === var v = async function await(): Promise { } >v : Symbol(v, Decl(asyncFunctionDeclaration12_es2017.ts, 0, 3)) ->await : Symbol(await, Decl(asyncFunctionDeclaration12_es2017.ts, 0, 22)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es2017.ts, 0, 7)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types index 46fd50a46e331..d2a4a00f1f56a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types @@ -1,7 +1,6 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts === var v = async function await(): Promise { } ->v : () => any ->async function : () => any ->await : any ->(): Promise { } : () => Promise +>v : () => Promise +>async function await(): Promise { } : () => Promise +>await : () => Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt index 353e75ca6d575..70d25a1ac25aa 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt @@ -1,16 +1,7 @@ -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,29): error TS1005: ',' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,47): error TS1005: '=>' expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,24): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts (4 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts (1 errors) ==== var v = async function await(): Promise { } ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. - ~ -!!! error TS1005: '=>' expected. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js index 19bca54f524a8..d74aa370bfbb9 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js @@ -2,9 +2,8 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es5.js] -var v = function () { +var v = function await() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -}, await; -(function () { }); +}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols index 688f265efcc6e..113b8c18933d9 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts === var v = async function await(): Promise { } >v : Symbol(v, Decl(asyncFunctionDeclaration12_es5.ts, 0, 3)) ->await : Symbol(await, Decl(asyncFunctionDeclaration12_es5.ts, 0, 22)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es5.ts, 0, 7)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types index 1432adc522d79..2feefbe43c02c 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types @@ -1,7 +1,6 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts === var v = async function await(): Promise { } ->v : () => any ->async function : () => any ->await : any ->(): Promise { } : () => Promise +>v : () => Promise +>async function await(): Promise { } : () => Promise +>await : () => Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt index ffe7227344f92..125dda8d46290 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -1,16 +1,7 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: ',' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts (4 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts (1 errors) ==== var v = async function await(): Promise { } ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: ',' expected. - ~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. - ~ -!!! error TS1005: '=>' expected. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js index 17829af6f20e2..d9982fab9337f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -2,7 +2,6 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es6.js] -var v = function () { +var v = function await() { return __awaiter(this, void 0, void 0, function* () { }); -}, await; -() => { }; +}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols index 86bec74c68d07..ec1bbc9f7456f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts === var v = async function await(): Promise { } >v : Symbol(v, Decl(asyncFunctionDeclaration12_es6.ts, 0, 3)) ->await : Symbol(await, Decl(asyncFunctionDeclaration12_es6.ts, 0, 22)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es6.ts, 0, 7)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types index 251b01f7dc0e5..2fc4113cb25af 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types @@ -1,7 +1,6 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts === var v = async function await(): Promise { } ->v : () => any ->async function : () => any ->await : any ->(): Promise { } : () => Promise +>v : () => Promise +>async function await(): Promise { } : () => Promise +>await : () => Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt index 2d110f68127fc..9b8504d2fa12d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -1,27 +1,8 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,28): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,36): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (7 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (1 errors) ==== async function foo(await): Promise { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js index 904bbe62f0ba8..f660de5229ece 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -3,6 +3,5 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es2017.js] -async function foo() { } -await; -Promise < void > {}; +async function foo(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols index 2a186f07ad94c..58a4fe62aa395 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts === async function foo(await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es2017.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration5_es2017.ts, 0, 19)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types index fb19a3f5b11b1..a1ae2eefdc6a0 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types @@ -1,11 +1,5 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts === async function foo(await): Promise { ->foo : () => any +>foo : (await: any) => Promise >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt index 6607ec7ff5c9f..5d37c723c6a9b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt @@ -1,27 +1,8 @@ -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,25): error TS1005: ';' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,26): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,28): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,36): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (7 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (1 errors) ==== async function foo(await): Promise { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js index 5f8f8f4273589..7ebe3a54f54cf 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js @@ -3,10 +3,10 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es5.js] -function foo() { - return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/]; - }); }); +function foo(await) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); } -await; -Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols index 5816bebe5ab46..50d7d0beafd67 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts === async function foo(await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es5.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration5_es5.ts, 0, 19)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.types b/tests/baselines/reference/asyncFunctionDeclaration5_es5.types index c1a99312825b4..093ce5645d80d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.types +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.types @@ -1,11 +1,5 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts === async function foo(await): Promise { ->foo : () => any +>foo : (await: any) => Promise >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt index ccddf6d5c044b..bc4832ffcae22 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -1,27 +1,8 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS1138: Parameter declaration expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,28): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,36): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (7 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (1 errors) ==== async function foo(await): Promise { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2304: Cannot find name 'await'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ - ~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS1109: Expression expected. - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{}'. \ No newline at end of file +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js index 9521b76041585..cb36ae4c3c253 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -3,8 +3,7 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es6.js] -function foo() { - return __awaiter(this, void 0, void 0, function* () { }); +function foo(await) { + return __awaiter(this, void 0, void 0, function* () { + }); } -await; -Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols index 74ff7be33d3e1..27e1ff6f5efb1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts === async function foo(await): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration5_es6.ts, 0, 19)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.types b/tests/baselines/reference/asyncFunctionDeclaration5_es6.types index 30497fd457ac8..58f5ccd8e489d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.types +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.types @@ -1,11 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts === async function foo(await): Promise { ->foo : () => any +>foo : (await: any) => Promise >await : any ->Promise {} : boolean ->PromisePromise : PromiseConstructor ->void : undefined -> : any ->{} : {} } diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.errors.txt b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.errors.txt index 6af732c1b4fb8..e5747e2499aab 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.errors.txt @@ -3,28 +3,16 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/asyncGeneratorProp tests/cases/conformance/parser/ecmascript2018/asyncGenerators/asyncGeneratorSetAccessorIsError.ts(2,17): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts(2,19): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts(3,14): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS2693: 'await' only refers to a type, but is being used as a value here. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,20): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,24): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,26): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,26): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,34): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,36): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,36): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldAsTypeIsStrictError.ts(4,16): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInClassComputedPropertyIsError.ts(2,14): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInClassComputedPropertyIsError.ts(2,14): error TS2693: 'yield' only refers to a type, but is being used as a value here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts(2,19): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS2693: 'yield' only refers to a type, but is being used as a value here. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,20): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts(3,16): error TS1109: Expression expected. @@ -43,32 +31,20 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa async * yield() { } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (1 errors) ==== class C4 { async * f(await) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2693: 'await' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } } - ~ -!!! error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (1 errors) ==== class C5 { async * f(yield) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2693: 'yield' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ';' expected. +!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. } } - ~ -!!! error TS1128: Declaration or statement expected. ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== class C6 { async * f(a = await 1) { @@ -90,51 +66,39 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa } } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (1 errors) ==== class C9 { async * f() { function yield() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. } } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (1 errors) ==== class C10 { async * f() { const x = function yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. }; } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (1 errors) ==== class C11 { async * f() { function await() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (1 errors) ==== class C12 { async * f() { const x = function await() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. }; } } diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.symbols b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.symbols index b3494dd007910..042e3043791a0 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.symbols +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.symbols @@ -28,6 +28,7 @@ class C4 { async * f(await) { >f : Symbol(C4.f, Decl(awaitParameterIsError.ts, 0, 10)) +>await : Symbol(await, Decl(awaitParameterIsError.ts, 1, 14)) } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === @@ -36,6 +37,7 @@ class C5 { async * f(yield) { >f : Symbol(C5.f, Decl(yieldParameterIsError.ts, 0, 10)) +>yield : Symbol(yield, Decl(yieldParameterIsError.ts, 1, 14)) } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === @@ -76,7 +78,7 @@ class C9 { >f : Symbol(C9.f, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 10)) function yield() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 1, 17)) +>yield : Symbol(yield, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 1, 17)) } } } @@ -89,6 +91,7 @@ class C10 { const x = function yield() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 2, 13)) +>yield : Symbol(yield, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 2, 17)) }; } @@ -101,7 +104,7 @@ class C11 { >f : Symbol(C11.f, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 11)) function await() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 1, 17)) +>await : Symbol(await, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 1, 17)) } } } @@ -114,6 +117,7 @@ class C12 { const x = function await() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 2, 13)) +>await : Symbol(await, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 2, 17)) }; } diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types index 68375a7d6796e..8de20801f686d 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types @@ -27,7 +27,7 @@ class C4 { >C4 : C4 async * f(await) { ->f : () => any +>f : (await: any) => AsyncGenerator >await : any } } @@ -36,7 +36,7 @@ class C5 { >C5 : C5 async * f(yield) { ->f : () => any +>f : (yield: any) => AsyncGenerator >yield : any } } @@ -78,12 +78,10 @@ class C9 { >C9 : C9 async * f() { ->f : () => AsyncGenerator<() => void, void, unknown> +>f : () => AsyncGenerator function yield() { -> : () => any ->yield() { } : any ->() { } : () => void +>yield : () => void } } } @@ -92,13 +90,12 @@ class C10 { >C10 : C10 async * f() { ->f : () => AsyncGenerator<() => void, void, unknown> +>f : () => AsyncGenerator const x = function yield() { ->x : () => any ->function : () => any ->yield() { } : any ->() { } : () => void +>x : () => void +>function yield() { } : () => void +>yield : () => void }; } @@ -111,10 +108,7 @@ class C11 { >f : () => AsyncGenerator function await() { -> : () => any ->await() : any ->() : any -> : any +>await : () => void } } } @@ -126,11 +120,9 @@ class C12 { >f : () => AsyncGenerator const x = function await() { ->x : () => any ->function : () => any ->await() : any ->() : any -> : any +>x : () => void +>function await() { } : () => void +>await : () => void }; } diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.errors.txt index bc020c474df0c..8db2f5f3c99df 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.errors.txt @@ -1,19 +1,12 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts(1,25): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,21): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,26): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,20): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,22): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,22): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,32): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,32): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,21): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts(1,25): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,21): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,26): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,21): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts(2,12): error TS1109: Expression expected. @@ -26,19 +19,15 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsOk.ts (0 errors) ==== async function * yield() { } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (1 errors) ==== async function * f4(await) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (1 errors) ==== async function * f5(yield) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== async function * f6(a = await 1) { @@ -55,42 +44,32 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa async function * g() { } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (1 errors) ==== async function * f9() { function yield() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (1 errors) ==== async function * f10() { const x = function yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. }; } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (1 errors) ==== async function * f11() { function await() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } } -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (1 errors) ==== async function * f12() { const x = function yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. }; } ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldIsOk.ts (0 errors) ==== diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.symbols b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.symbols index cfc9034846cc5..791c9e4dde349 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.symbols +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.symbols @@ -13,12 +13,12 @@ async function * yield() { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === async function * f4(await) { >f4 : Symbol(f4, Decl(awaitParameterIsError.ts, 0, 0)) ->await : Symbol(await, Decl(awaitNameIsOk.ts, 0, 0), Decl(awaitAsTypeIsOk.ts, 0, 0)) +>await : Symbol(await, Decl(awaitParameterIsError.ts, 0, 20)) } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === async function * f5(yield) { >f5 : Symbol(f5, Decl(yieldParameterIsError.ts, 0, 0)) ->yield : Symbol(yield, Decl(yieldNameIsOk.ts, 0, 0), Decl(yieldAsTypeIsOk.ts, 0, 0)) +>yield : Symbol(yield, Decl(yieldParameterIsError.ts, 0, 20)) } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === async function * f6(a = await 1) { @@ -43,7 +43,7 @@ async function * f9() { >f9 : Symbol(f9, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 0)) function yield() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 23)) +>yield : Symbol(yield, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 23)) } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === @@ -52,6 +52,7 @@ async function * f10() { const x = function yield() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 1, 9)) +>yield : Symbol(yield, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 1, 13)) }; } @@ -60,7 +61,7 @@ async function * f11() { >f11 : Symbol(f11, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 0)) function await() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 24)) +>await : Symbol(await, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 24)) } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === @@ -69,6 +70,7 @@ async function * f12() { const x = function yield() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 1, 9)) +>yield : Symbol(yield, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 1, 13)) }; } diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types index 08190b40112f5..668567c29ce12 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types @@ -12,13 +12,13 @@ async function * yield() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === async function * f4(await) { ->f4 : () => any ->await : () => AsyncGenerator +>f4 : (await: any) => AsyncGenerator +>await : any } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === async function * f5(yield) { ->f5 : () => any ->yield : () => AsyncGenerator +>f5 : (yield: any) => AsyncGenerator +>yield : any } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === async function * f6(a = await 1) { @@ -43,23 +43,20 @@ async function * f8() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === async function * f9() { ->f9 : () => AsyncGenerator<() => void, void, unknown> +>f9 : () => AsyncGenerator function yield() { -> : () => any ->yield() { } : any ->() { } : () => void +>yield : () => void } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === async function * f10() { ->f10 : () => AsyncGenerator<() => void, void, unknown> +>f10 : () => AsyncGenerator const x = function yield() { ->x : () => any ->function : () => any ->yield() { } : any ->() { } : () => void +>x : () => void +>function yield() { } : () => void +>yield : () => void }; } @@ -68,21 +65,17 @@ async function * f11() { >f11 : () => AsyncGenerator function await() { -> : () => any ->await() : any ->() : any -> : any +>await : () => void } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === async function * f12() { ->f12 : () => AsyncGenerator<() => void, void, unknown> +>f12 : () => AsyncGenerator const x = function yield() { ->x : () => any ->function : () => any ->yield() { } : any ->() { } : () => void +>x : () => void +>function yield() { } : () => void +>yield : () => void }; } diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.errors.txt index 43d2eb414b213..298b24e1bf05d 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.errors.txt @@ -1,79 +1,39 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts(1,34): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts(1,29): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'await'. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts(1,37): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'await'. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,35): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,20): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,22): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,22): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,30): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,32): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,32): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts(1,29): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(1,30): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts(1,34): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts(1,29): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'yield'. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts(1,37): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'yield'. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,35): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts(1,29): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(1,30): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts(2,12): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/functionExpressionIsOk.ts (0 errors) ==== const f1 = async function * f() { }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts (1 errors) ==== const f2 = async function * await() { ~~~~~ -!!! error TS1005: '(' expected. - ~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'await'. -!!! related TS6203 tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts:1:30: 'await' was also declared here. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1005: '=>' expected. - }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts (4 errors) ==== +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. + }; +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts (1 errors) ==== const f3 = async function * yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'yield'. -!!! related TS6203 tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts:1:30: 'yield' was also declared here. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1005: '=>' expected. - }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (3 errors) ==== +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. + }; +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (1 errors) ==== const f4 = async function * (await) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'await'. -!!! related TS6203 tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts:1:29: 'await' was also declared here. - ~ -!!! error TS1005: ',' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (1 errors) ==== const f5 = async function * (yield) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'yield'. -!!! related TS6203 tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts:1:29: 'yield' was also declared here. - ~ -!!! error TS1005: ',' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. }; ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== const f6 = async function * (a = await 1) { @@ -90,44 +50,32 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa async function * g() { } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (1 errors) ==== const f9 = async function * () { function yield() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (1 errors) ==== const f10 = async function * () { const x = function yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. }; }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (1 errors) ==== const f11 = async function * () { function await() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (1 errors) ==== const f12 = async function * () { const x = function await() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. }; }; ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldIsOk.ts (0 errors) ==== diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.symbols b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.symbols index b914ecf1eaf16..67d1da450c236 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.symbols +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.symbols @@ -7,13 +7,13 @@ const f1 = async function * f() { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts === const f2 = async function * await() { >f2 : Symbol(f2, Decl(awaitNameIsError.ts, 0, 5)) ->await : Symbol(await, Decl(awaitNameIsError.ts, 0, 27), Decl(awaitAsTypeIsOk.ts, 0, 0)) +>await : Symbol(await, Decl(awaitNameIsError.ts, 0, 10)) }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts === const f3 = async function * yield() { >f3 : Symbol(f3, Decl(yieldNameIsError.ts, 0, 5)) ->yield : Symbol(yield, Decl(yieldNameIsError.ts, 0, 27), Decl(yieldAsTypeIsOk.ts, 0, 0)) +>yield : Symbol(yield, Decl(yieldNameIsError.ts, 0, 10)) }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === @@ -53,7 +53,7 @@ const f9 = async function * () { >f9 : Symbol(f9, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 5)) function yield() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 32)) +>yield : Symbol(yield, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 32)) } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === @@ -62,6 +62,7 @@ const f10 = async function * () { const x = function yield() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 1, 9)) +>yield : Symbol(yield, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 1, 13)) }; }; @@ -70,7 +71,7 @@ const f11 = async function * () { >f11 : Symbol(f11, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 5)) function await() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 33)) +>await : Symbol(await, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 33)) } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === @@ -79,6 +80,7 @@ const f12 = async function * () { const x = function await() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 1, 9)) +>await : Symbol(await, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 1, 13)) }; }; @@ -120,26 +122,26 @@ const f18 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitAsTypeIsOk.ts === interface await {} ->await : Symbol(await, Decl(awaitNameIsError.ts, 0, 27), Decl(awaitAsTypeIsOk.ts, 0, 0)) +>await : Symbol(await, Decl(awaitAsTypeIsOk.ts, 0, 0)) const f19 = async function * () { >f19 : Symbol(f19, Decl(awaitAsTypeIsOk.ts, 1, 5)) let x: await; >x : Symbol(x, Decl(awaitAsTypeIsOk.ts, 2, 7)) ->await : Symbol(await, Decl(awaitNameIsError.ts, 0, 27), Decl(awaitAsTypeIsOk.ts, 0, 0)) +>await : Symbol(await, Decl(awaitAsTypeIsOk.ts, 0, 0)) }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldAsTypeIsOk.ts === interface yield {} ->yield : Symbol(yield, Decl(yieldNameIsError.ts, 0, 27), Decl(yieldAsTypeIsOk.ts, 0, 0)) +>yield : Symbol(yield, Decl(yieldAsTypeIsOk.ts, 0, 0)) const f20 = async function * () { >f20 : Symbol(f20, Decl(yieldAsTypeIsOk.ts, 1, 5)) let x: yield; >x : Symbol(x, Decl(yieldAsTypeIsOk.ts, 2, 7)) ->yield : Symbol(yield, Decl(yieldNameIsError.ts, 0, 27), Decl(yieldAsTypeIsOk.ts, 0, 0)) +>yield : Symbol(yield, Decl(yieldAsTypeIsOk.ts, 0, 0)) }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts === diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types index 0af07dc220f33..071b5834b3ed8 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types @@ -7,31 +7,29 @@ const f1 = async function * f() { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts === const f2 = async function * await() { ->f2 : () => any ->async function * : () => any ->await : any ->() {} : () => void +>f2 : () => AsyncGenerator +>async function * await() {} : () => AsyncGenerator +>await : () => AsyncGenerator }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsError.ts === const f3 = async function * yield() { ->f3 : () => any ->async function * : () => any ->yield : any ->() {} : () => void +>f3 : () => AsyncGenerator +>async function * yield() {} : () => AsyncGenerator +>yield : () => AsyncGenerator }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === const f4 = async function * (await) { ->f4 : () => any ->async function * ( : () => any +>f4 : (await: any) => AsyncGenerator +>async function * (await) {} : (await: any) => AsyncGenerator >await : any }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === const f5 = async function * (yield) { ->f5 : () => any ->async function * ( : () => any +>f5 : (yield: any) => AsyncGenerator +>async function * (yield) {} : (yield: any) => AsyncGenerator >yield : any }; @@ -63,25 +61,22 @@ const f8 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === const f9 = async function * () { ->f9 : () => AsyncGenerator<() => void, void, unknown> ->async function * () { function yield() { }} : () => AsyncGenerator<() => void, void, unknown> +>f9 : () => AsyncGenerator +>async function * () { function yield() { }} : () => AsyncGenerator function yield() { -> : () => any ->yield() { } : any ->() { } : () => void +>yield : () => void } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === const f10 = async function * () { ->f10 : () => AsyncGenerator<() => void, void, unknown> ->async function * () { const x = function yield() { };} : () => AsyncGenerator<() => void, void, unknown> +>f10 : () => AsyncGenerator +>async function * () { const x = function yield() { };} : () => AsyncGenerator const x = function yield() { ->x : () => any ->function : () => any ->yield() { } : any ->() { } : () => void +>x : () => void +>function yield() { } : () => void +>yield : () => void }; }; @@ -91,10 +86,7 @@ const f11 = async function * () { >async function * () { function await() { }} : () => AsyncGenerator function await() { -> : () => any ->await() : any ->() : any -> : any +>await : () => void } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === @@ -103,11 +95,9 @@ const f12 = async function * () { >async function * () { const x = function await() { };} : () => AsyncGenerator const x = function await() { ->x : () => any ->function : () => any ->await() : any ->() : any -> : any +>x : () => void +>function await() { } : () => void +>await : () => void }; }; diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.errors.txt b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.errors.txt index e0f8adbab15a2..d64ea22f8b2fa 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.errors.txt @@ -3,27 +3,13 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/asyncGeneratorProp tests/cases/conformance/parser/ecmascript2018/asyncGenerators/asyncGeneratorSetAccessorIsError.ts(2,17): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts(2,19): error TS2524: 'await' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts(3,14): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS2693: 'await' only refers to a type, but is being used as a value here. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,20): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,22): error TS1136: Property assignment expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,24): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,26): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,26): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,34): error TS1109: Expression expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,36): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1005: '(' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,36): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts(2,19): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS2693: 'yield' only refers to a type, but is being used as a value here. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,20): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,22): error TS1136: Property assignment expected. -tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts(3,16): error TS1109: Expression expected. @@ -42,36 +28,20 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa async * yield() { } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (5 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts (1 errors) ==== const o4 = { async * f(await) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2693: 'await' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1136: Property assignment expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } }; - ~ -!!! error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (5 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts (1 errors) ==== const o5 = { async * f(yield) { ~~~~~ -!!! error TS1138: Parameter declaration expected. - ~~~~~ -!!! error TS2693: 'yield' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1136: Property assignment expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } }; - ~ -!!! error TS1128: Declaration or statement expected. ==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== const o6 = { async * f(a = await 1) { @@ -93,51 +63,39 @@ tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingVa } } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (1 errors) ==== const o9 = { async * f() { function yield() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. } } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (1 errors) ==== const o10 = { async * f() { const x = function yield() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1005: '=>' expected. +!!! error TS1359: Identifier expected. 'yield' is a reserved word that cannot be used here. }; } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (1 errors) ==== const o11 = { async * f() { function await() { ~~~~~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. } } }; -==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (1 errors) ==== const o12 = { async * f() { const x = function await() { ~~~~~ -!!! error TS1005: '(' expected. - ~ -!!! error TS1109: Expression expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here. }; } }; diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.symbols b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.symbols index acc79db8e8e0b..57d16f0ee8393 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.symbols +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.symbols @@ -78,7 +78,7 @@ const o9 = { >f : Symbol(f, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 0, 12)) function yield() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 1, 17)) +>yield : Symbol(yield, Decl(nestedFunctionDeclarationNamedYieldIsError.ts, 1, 17)) } } }; @@ -91,6 +91,7 @@ const o10 = { const x = function yield() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 2, 13)) +>yield : Symbol(yield, Decl(nestedFunctionExpressionNamedYieldIsError.ts, 2, 17)) }; } @@ -103,7 +104,7 @@ const o11 = { >f : Symbol(f, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 0, 13)) function await() { -> : Symbol((Missing), Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 1, 17)) +>await : Symbol(await, Decl(nestedFunctionDeclarationNamedAwaitIsError.ts, 1, 17)) } } }; @@ -116,6 +117,7 @@ const o12 = { const x = function await() { >x : Symbol(x, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 2, 13)) +>await : Symbol(await, Decl(nestedFunctionExpressionNamedAwaitIsError.ts, 2, 17)) }; } diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types index 5a6ea2a19fb81..b9ec519e0e918 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types @@ -27,21 +27,21 @@ const o3 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === const o4 = { ->o4 : { f(): any; await: any; } ->{ async * f(await) : { f(): any; await: any; } +>o4 : { f(await: any): AsyncGenerator; } +>{ async * f(await) { }} : { f(await: any): AsyncGenerator; } async * f(await) { ->f : () => any +>f : (await: any) => AsyncGenerator >await : any } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === const o5 = { ->o5 : { f(): any; yield: any; } ->{ async * f(yield) : { f(): any; yield: any; } +>o5 : { f(yield: any): AsyncGenerator; } +>{ async * f(yield) { }} : { f(yield: any): AsyncGenerator; } async * f(yield) { ->f : () => any +>f : (yield: any) => AsyncGenerator >yield : any } }; @@ -83,32 +83,29 @@ const o8 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === const o9 = { ->o9 : { f(): AsyncGenerator<() => void, void, unknown>; } ->{ async * f() { function yield() { } }} : { f(): AsyncGenerator<() => void, void, unknown>; } +>o9 : { f(): AsyncGenerator; } +>{ async * f() { function yield() { } }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncGenerator<() => void, void, unknown> +>f : () => AsyncGenerator function yield() { -> : () => any ->yield() { } : any ->() { } : () => void +>yield : () => void } } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === const o10 = { ->o10 : { f(): AsyncGenerator<() => void, void, unknown>; } ->{ async * f() { const x = function yield() { }; }} : { f(): AsyncGenerator<() => void, void, unknown>; } +>o10 : { f(): AsyncGenerator; } +>{ async * f() { const x = function yield() { }; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncGenerator<() => void, void, unknown> +>f : () => AsyncGenerator const x = function yield() { ->x : () => any ->function : () => any ->yield() { } : any ->() { } : () => void +>x : () => void +>function yield() { } : () => void +>yield : () => void }; } @@ -122,10 +119,7 @@ const o11 = { >f : () => AsyncGenerator function await() { -> : () => any ->await() : any ->() : any -> : any +>await : () => void } } }; @@ -138,11 +132,9 @@ const o12 = { >f : () => AsyncGenerator const x = function await() { ->x : () => any ->function : () => any ->await() : any ->() : any -> : any +>x : () => void +>function await() { } : () => void +>await : () => void }; } diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt index b0eb67d7c7d48..659262179f7f0 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt @@ -59,6 +59,19 @@ tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level // await allowed in aliased import import { await as _await } from "./other"; + // newlines + // await in throw + throw await + 1; + + // await in var + let y = await + 1; + + // await in expression statement; + await + 1; + ==== tests/cases/conformance/externalModules/other.ts (0 errors) ==== const _await = 1; diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).js b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).js index 55c20cc289c5d..5cf6aa277f641 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).js +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).js @@ -52,6 +52,19 @@ class C { // await allowed in aliased import import { await as _await } from "./other"; + +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await + 1; + +// await in expression statement; +await + 1; //// [other.ts] const _await = 1; @@ -106,3 +119,10 @@ let C = class C { C = __decorate([ (await dec) ], C); +// newlines +// await in throw +throw await 1; +// await in var +let y = await 1; +// await in expression statement; +await 1; diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).symbols b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).symbols index 992258ff5dfdf..ed823db8bc9ee 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).symbols +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).symbols @@ -102,6 +102,21 @@ import { await as _await } from "./other"; >await : Symbol(await, Decl(other.ts, 3, 8)) >_await : Symbol(_await, Decl(index.ts, 50, 8)) +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await +>y : Symbol(y, Decl(index.ts, 58, 3)) + + 1; + +// await in expression statement; +await + 1; + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : Symbol(_await, Decl(other.ts, 0, 5)) diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).types b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).types index b2a82b1bea73a..3d24af5ccdeeb 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).types +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).types @@ -143,6 +143,29 @@ import { await as _await } from "./other"; >await : 1 >_await : 1 +// newlines +// await in throw +throw await +>await 1 : 1 + + 1; +>1 : 1 + +// await in var +let y = await +>y : number +>await 1 : 1 + + 1; +>1 : 1 + +// await in expression statement; +await +>await 1 : 1 + + 1; +>1 : 1 + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : 1 diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).js b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).js index 55c20cc289c5d..5cf6aa277f641 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).js +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).js @@ -52,6 +52,19 @@ class C { // await allowed in aliased import import { await as _await } from "./other"; + +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await + 1; + +// await in expression statement; +await + 1; //// [other.ts] const _await = 1; @@ -106,3 +119,10 @@ let C = class C { C = __decorate([ (await dec) ], C); +// newlines +// await in throw +throw await 1; +// await in var +let y = await 1; +// await in expression statement; +await 1; diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).symbols b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).symbols index 992258ff5dfdf..ed823db8bc9ee 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).symbols +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).symbols @@ -102,6 +102,21 @@ import { await as _await } from "./other"; >await : Symbol(await, Decl(other.ts, 3, 8)) >_await : Symbol(_await, Decl(index.ts, 50, 8)) +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await +>y : Symbol(y, Decl(index.ts, 58, 3)) + + 1; + +// await in expression statement; +await + 1; + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : Symbol(_await, Decl(other.ts, 0, 5)) diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).types b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).types index b2a82b1bea73a..3d24af5ccdeeb 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).types +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2017).types @@ -143,6 +143,29 @@ import { await as _await } from "./other"; >await : 1 >_await : 1 +// newlines +// await in throw +throw await +>await 1 : 1 + + 1; +>1 : 1 + +// await in var +let y = await +>y : number +>await 1 : 1 + + 1; +>1 : 1 + +// await in expression statement; +await +>await 1 : 1 + + 1; +>1 : 1 + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : 1 diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt index b0eb67d7c7d48..659262179f7f0 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt @@ -59,6 +59,19 @@ tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level // await allowed in aliased import import { await as _await } from "./other"; + // newlines + // await in throw + throw await + 1; + + // await in var + let y = await + 1; + + // await in expression statement; + await + 1; + ==== tests/cases/conformance/externalModules/other.ts (0 errors) ==== const _await = 1; diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).js b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).js index 172e302f2418e..082a4d2188e1a 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).js +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).js @@ -52,6 +52,19 @@ class C { // await allowed in aliased import import { await as _await } from "./other"; + +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await + 1; + +// await in expression statement; +await + 1; //// [other.ts] const _await = 1; @@ -75,7 +88,7 @@ System.register([], function (exports_1, context_1) { //// [index.js] System.register([], function (exports_1, context_1) { "use strict"; - var x, C1, C2, C3, C; + var x, C1, C2, C3, C, y; var __moduleName = context_1 && context_1.id; return { setters: [], @@ -122,6 +135,13 @@ System.register([], function (exports_1, context_1) { C = __decorate([ (await dec) ], C); + // newlines + // await in throw + throw await 1; + // await in var + y = await 1; + // await in expression statement; + await 1; } }; }); diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).symbols b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).symbols index 992258ff5dfdf..ed823db8bc9ee 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).symbols +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).symbols @@ -102,6 +102,21 @@ import { await as _await } from "./other"; >await : Symbol(await, Decl(other.ts, 3, 8)) >_await : Symbol(_await, Decl(index.ts, 50, 8)) +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await +>y : Symbol(y, Decl(index.ts, 58, 3)) + + 1; + +// await in expression statement; +await + 1; + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : Symbol(_await, Decl(other.ts, 0, 5)) diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).types b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).types index b2a82b1bea73a..3d24af5ccdeeb 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).types +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).types @@ -143,6 +143,29 @@ import { await as _await } from "./other"; >await : 1 >_await : 1 +// newlines +// await in throw +throw await +>await 1 : 1 + + 1; +>1 : 1 + +// await in var +let y = await +>y : number +>await 1 : 1 + + 1; +>1 : 1 + +// await in expression statement; +await +>await 1 : 1 + + 1; +>1 : 1 + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : 1 diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).js b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).js index 172e302f2418e..082a4d2188e1a 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).js +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).js @@ -52,6 +52,19 @@ class C { // await allowed in aliased import import { await as _await } from "./other"; + +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await + 1; + +// await in expression statement; +await + 1; //// [other.ts] const _await = 1; @@ -75,7 +88,7 @@ System.register([], function (exports_1, context_1) { //// [index.js] System.register([], function (exports_1, context_1) { "use strict"; - var x, C1, C2, C3, C; + var x, C1, C2, C3, C, y; var __moduleName = context_1 && context_1.id; return { setters: [], @@ -122,6 +135,13 @@ System.register([], function (exports_1, context_1) { C = __decorate([ (await dec) ], C); + // newlines + // await in throw + throw await 1; + // await in var + y = await 1; + // await in expression statement; + await 1; } }; }); diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).symbols b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).symbols index 992258ff5dfdf..ed823db8bc9ee 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).symbols +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).symbols @@ -102,6 +102,21 @@ import { await as _await } from "./other"; >await : Symbol(await, Decl(other.ts, 3, 8)) >_await : Symbol(_await, Decl(index.ts, 50, 8)) +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await +>y : Symbol(y, Decl(index.ts, 58, 3)) + + 1; + +// await in expression statement; +await + 1; + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : Symbol(_await, Decl(other.ts, 0, 5)) diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).types b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).types index b2a82b1bea73a..3d24af5ccdeeb 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).types +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2017).types @@ -143,6 +143,29 @@ import { await as _await } from "./other"; >await : 1 >_await : 1 +// newlines +// await in throw +throw await +>await 1 : 1 + + 1; +>1 : 1 + +// await in var +let y = await +>y : number +>await 1 : 1 + + 1; +>1 : 1 + +// await in expression statement; +await +>await 1 : 1 + + 1; +>1 : 1 + === tests/cases/conformance/externalModules/other.ts === const _await = 1; >_await : 1 diff --git a/tests/baselines/reference/topLevelAwaitErrors.1.errors.txt b/tests/baselines/reference/topLevelAwaitErrors.1.errors.txt index d2e7ffcb15a17..773e8446a6fda 100644 --- a/tests/baselines/reference/topLevelAwaitErrors.1.errors.txt +++ b/tests/baselines/reference/topLevelAwaitErrors.1.errors.txt @@ -5,8 +5,12 @@ tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(5,16): error TS 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(11,22): error TS1109: Expression expected. +tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(11,23): error TS2693: 'string' only refers to a type, but is being used as a value here. +tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(11,29): error TS1005: ',' 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(18,8): error TS2304: Cannot find name 'x'. 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. @@ -16,7 +20,7 @@ tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(41,14): error T tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(42,20): error TS1109: Expression expected. -==== tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts (16 errors) ==== +==== tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts (20 errors) ==== export {}; // reparse call as invalid await should error @@ -42,6 +46,12 @@ tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(42,20): error T class C extends await { ~~~~~ !!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~ +!!! error TS1005: ',' expected. } // await in class decorators should fail @@ -53,6 +63,8 @@ tests/cases/conformance/externalModules/topLevelAwaitErrors.1.ts(42,20): error T @await(x) ~~~~~ !!! error TS1109: Expression expected. + ~ +!!! error TS2304: Cannot find name 'x'. class C2 {} @await diff --git a/tests/baselines/reference/topLevelAwaitErrors.1.js b/tests/baselines/reference/topLevelAwaitErrors.1.js index 566c86afe4929..175321a0513f8 100644 --- a/tests/baselines/reference/topLevelAwaitErrors.1.js +++ b/tests/baselines/reference/topLevelAwaitErrors.1.js @@ -51,7 +51,7 @@ await , string > (1); // reparse tagged template as invalid await should error await , string > ``; // reparse class extends clause should fail -class C extends { +class C extends string { } // await in class decorators should fail let C1 = class C1 { @@ -62,6 +62,7 @@ C1 = __decorate([ let C2 = class C2 { }; C2 = __decorate([ + (x) ], C2); let C3 = class C3 { }; @@ -77,6 +78,7 @@ class C5 { ["foo"]() { } } __decorate([ + (1) ], C5.prototype, "foo", null); class C6 { ["foo"]() { } @@ -94,7 +96,7 @@ __decorate([ __param(0, ) ], C7.prototype, "method1", null); __decorate([ - __param(0, ) + __param(0, (1)) ], C7.prototype, "method2", null); __decorate([ __param(0, (await )) diff --git a/tests/baselines/reference/topLevelAwaitErrors.1.types b/tests/baselines/reference/topLevelAwaitErrors.1.types index 5f3a5e323c722..7e8efc49dce7f 100644 --- a/tests/baselines/reference/topLevelAwaitErrors.1.types +++ b/tests/baselines/reference/topLevelAwaitErrors.1.types @@ -32,7 +32,7 @@ await ``; // reparse class extends clause should fail class C extends await { >C : C -> : any +>string : any } // await in class decorators should fail @@ -45,7 +45,9 @@ class C1 {} >C1 : C1 @await(x) +>await(x) : any > : any +>x : any class C2 {} >C2 : C2 @@ -71,7 +73,9 @@ class C5 { >C5 : C5 @await(1) +>await(1) : any > : any +>1 : 1 ["foo"]() {} >["foo"] : () => void @@ -101,7 +105,9 @@ class C7 { method2(@await(1) [x]) {} >method2 : ([x]: [any]) => void +>await(1) : any > : any +>1 : 1 >x : any method3(@(await) [x]) {} diff --git a/tests/cases/conformance/externalModules/topLevelAwait.1.ts b/tests/cases/conformance/externalModules/topLevelAwait.1.ts index dbee4b33013d3..afa8d4d1a2b43 100644 --- a/tests/cases/conformance/externalModules/topLevelAwait.1.ts +++ b/tests/cases/conformance/externalModules/topLevelAwait.1.ts @@ -55,6 +55,19 @@ class C { // await allowed in aliased import import { await as _await } from "./other"; +// newlines +// await in throw +throw await + 1; + +// await in var +let y = await + 1; + +// await in expression statement; +await + 1; + // @filename: other.ts const _await = 1;