From 0c967f95007785539d8f604cff73143e0f0a5108 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 28 Feb 2021 16:31:17 -0500 Subject: [PATCH 01/17] Specific diagnostic suggestions for unexpected keywords or identifier --- src/compiler/diagnosticMessages.json | 48 ++++ src/compiler/parser.ts | 139 +++++++++- .../reference/ClassDeclaration26.errors.txt | 6 +- .../reference/anonymousModules.errors.txt | 12 +- .../reference/classUpdateTests.errors.txt | 16 +- .../commonMissingSemicolons.errors.txt | 259 ++++++++++++++++++ .../reference/commonMissingSemicolons.js | 164 +++++++++++ .../reference/commonMissingSemicolons.symbols | 93 +++++++ .../reference/commonMissingSemicolons.types | 164 +++++++++++ .../decoratorOnClassAccessor3.errors.txt | 4 +- .../decoratorOnClassAccessor6.errors.txt | 4 +- .../decoratorOnClassMethod3.errors.txt | 4 +- .../decoratorOnClassProperty3.errors.txt | 4 +- ...perCallsInNonConstructorMembers.errors.txt | 103 +------ ...dClassSuperCallsInNonConstructorMembers.js | 62 ++--- ...sSuperCallsInNonConstructorMembers.symbols | 16 ++ ...assSuperCallsInNonConstructorMembers.types | 30 +- ...s6ImportNamedImportParsingError.errors.txt | 12 +- .../baselines/reference/extension.errors.txt | 6 +- .../reference/externModule.errors.txt | 10 +- .../reference/innerModExport1.errors.txt | 4 +- .../reference/innerModExport2.errors.txt | 4 +- .../interfaceDeclaration4.errors.txt | 6 +- .../reference/interfaceNaming1.errors.txt | 4 +- ...facesWithPredefinedTypesAsNames.errors.txt | 4 +- ...lidSyntaxNamespaceImportWithAMD.errors.txt | 5 +- ...ntaxNamespaceImportWithCommonjs.errors.txt | 5 +- ...SyntaxNamespaceImportWithSystem.errors.txt | 5 +- .../parseErrorIncorrectReturnToken.errors.txt | 6 +- ...mericSeparators.decmialNegative.errors.txt | 18 +- .../reference/parser0_004152.errors.txt | 9 +- ...overy_IncompleteMemberVariable2.errors.txt | 4 +- .../reference/parserFuzz1.errors.txt | 9 +- .../parserSkippedTokens16.errors.txt | 6 +- .../parserUnterminatedGeneric2.errors.txt | 6 +- ...vateInstanceMemberAccessibility.errors.txt | 4 +- .../reservedNamesInAliases.errors.txt | 4 +- .../reference/reservedWords2.errors.txt | 4 +- .../templateStringInModuleName.errors.txt | 24 +- .../templateStringInModuleNameES6.errors.txt | 24 +- .../thisTypeInFunctionsNegative.errors.txt | 6 +- ... expected syntactic diagnostics.errors.txt | 6 +- ...tactic diagnostics.oldTranspile.errors.txt | 6 +- .../reference/typeAssertions.errors.txt | 8 +- .../typeGuardFunctionErrors.errors.txt | 19 +- .../cases/compiler/commonMissingSemicolons.ts | 51 ++++ 46 files changed, 1119 insertions(+), 288 deletions(-) create mode 100644 tests/baselines/reference/commonMissingSemicolons.errors.txt create mode 100644 tests/baselines/reference/commonMissingSemicolons.js create mode 100644 tests/baselines/reference/commonMissingSemicolons.symbols create mode 100644 tests/baselines/reference/commonMissingSemicolons.types create mode 100644 tests/cases/compiler/commonMissingSemicolons.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b23bfbf7ea423..3383a6fcda8e1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1360,6 +1360,50 @@ "category": "Error", "code": 1432 }, + "Unexpected keyword or identifier.": { + "category": "Error", + "code": 1433 + }, + "Unknown keyword or identifier. Did you mean '{0}'?": { + "category": "Error", + "code": 1434 + }, + "Decorators must precede all other keywords for property declarations.": { + "category": "Error", + "code": 1435 + }, + "Namespace must be given a name.": { + "category": "Error", + "code": 1436 + }, + "Interface must be given a name.": { + "category": "Error", + "code": 1437 + }, + "Type alias must be given a name.": { + "category": "Error", + "code": 1438 + }, + "Variable declaration not allowed at this location.": { + "category": "Error", + "code": 1439 + }, + "Function call not allowed at this location.": { + "category": "Error", + "code": 1440 + }, + "Missing '=' before default property value.": { + "category": "Error", + "code": 1441 + }, + "Template literal not allowed as a string at this position.": { + "category": "Error", + "code": 1442 + }, + "Template literal not allowed as a string at this position. Did you mean '{0}'?": { + "category": "Error", + "code": 1443 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", @@ -3264,6 +3308,10 @@ "category": "Error", "code": 2802 }, + "Namespace name cannot be '{0}'.": { + "category": "Error", + "code": 2803 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 01f42d64917e6..27ef130e1143f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1518,6 +1518,139 @@ namespace ts { return false; } + const commonKeywords = [ + "async", + "class", + "const", + "declare", + "export", + "function", + "interface", + "let", + "type", + "var", + ]; + + function parseSemicolonAfter(expression: Expression | PropertyName) { + // Consume the semicolon if it was explicitly provided. + if (canParseSemicolon()) { + if (token() === SyntaxKind.SemicolonToken) { + nextToken(); + } + + return; + } + + // Specialized diagnostics for a keyword expression are redundant if the related token is already complaining. + const lastError = lastOrUndefined(parseDiagnostics); + if (lastError && scanner.getTokenPos() < lastError.start + 2) { + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); + return; + } + + // Tagged template literals are sometimes used in places where only simple strings are allowed, e.g.: + // module `M1` { + // ^^^^^^^^^^^ This block is parsed as a template literal as with module`M1`. + if (isTaggedTemplateExpression(expression)) { + parseErrorAt(skipTrivia(sourceText, expression.template.pos), expression.template.end, Diagnostics.Template_literal_not_allowed_as_a_string_at_this_position); + return; + } + + // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. + const expressionText = getExpressionText(expression); + if (!expressionText || !isIdentifierText(expressionText, languageVersion)) { + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); + return; + } + + const pos = skipTrivia(sourceText, expression.pos); + + // Some known keywords are likely signs of syntax being used improperly. + switch (expressionText) { + case "const": + case "let": + case "var": + parseErrorAt(pos, expression.end, Diagnostics.Variable_declaration_not_allowed_at_this_location); + return; + + case "interface": + parseErrorForExpectedName(scanner.getTokenText(), "{", Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0); + return; + + case "is": + parseErrorAt(pos, scanner.getTextPos(), Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + return; + + case "module": + case "namespace": + parseErrorForExpectedName(scanner.getTokenText(), "{", Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0); + return; + + case "type": + parseErrorForExpectedName(scanner.getTokenText(), "=", Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0); + return; + } + + // The user alternately might have misspelled or forgotten to add a space after a common keyword. + const suggestion = getSpellingSuggestion(expressionText, commonKeywords, n => n) || getSpaceSuggestion(expressionText); + if (suggestion) { + parseErrorAt(pos, expression.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); + } + + // We know this is a slightly more precise case than a missing expected semicolon. + parseErrorAt(pos, expression.end, Diagnostics.Unexpected_keyword_or_identifier); + } + + function parseErrorForExpectedName(name: string, normalToken: string, blankDiagnostic: DiagnosticMessage, nameDiagnostic: DiagnosticMessage) { + if (name === normalToken) { + parseErrorAtCurrentToken(blankDiagnostic); + } + else { + parseErrorAtCurrentToken(nameDiagnostic, name); + } + } + + function getSpaceSuggestion(expressionText: string) { + for (const keyword of commonKeywords) { + if (expressionText.length > keyword.length + 2 && startsWith(expressionText, keyword)) { + return `${keyword} ${expressionText.slice(keyword.length)}`; + } + } + + return undefined; + } + + function parseSemicolonAfterPropertyName(name: PropertyName, type: TypeNode | undefined, initializer: Expression | undefined) { + switch (scanner.getTokenText()) { + case "@": + parseErrorAtCurrentToken(Diagnostics.Decorators_must_precede_all_other_keywords_for_property_declarations); + return; + + case "(": + parseErrorAtCurrentToken(Diagnostics.Function_call_not_allowed_at_this_location); + nextToken(); + return; + } + + if (type && !canParseSemicolon()) { + if (initializer) { + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); + } + else { + parseErrorAtCurrentToken(Diagnostics.Missing_before_default_property_value); + } + return; + } + + return parseSemicolonAfter(name); + } + + function getExpressionText(expression: Expression | PropertyName) { + return expression && ts.isIdentifier(expression) + ? expression.escapedText.toString() + : undefined; + } + function parseExpectedJSDoc(kind: JSDocSyntaxKind) { if (token() === kind) { nextTokenJSDoc(); @@ -5786,7 +5919,7 @@ namespace ts { identifierCount++; expression = finishNode(factory.createIdentifier(""), getNodePos()); } - parseSemicolon(); + parseSemicolonAfter(expression); return finishNode(factory.createThrowStatement(expression), pos); } @@ -5847,7 +5980,7 @@ namespace ts { node = factory.createLabeledStatement(expression, parseStatement()); } else { - parseSemicolon(); + parseSemicolonAfter(expression); node = factory.createExpressionStatement(expression); if (hasParen) { // do not parse the same jsdoc twice @@ -6440,7 +6573,7 @@ namespace ts { const exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(SyntaxKind.ExclamationToken) : undefined; const type = parseTypeAnnotation(); const initializer = doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.AwaitContext | NodeFlags.DisallowInContext, parseInitializer); - parseSemicolon(); + parseSemicolonAfterPropertyName(name, type, initializer); const node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } diff --git a/tests/baselines/reference/ClassDeclaration26.errors.txt b/tests/baselines/reference/ClassDeclaration26.errors.txt index 0972a287de3bc..1618901306ea7 100644 --- a/tests/baselines/reference/ClassDeclaration26.errors.txt +++ b/tests/baselines/reference/ClassDeclaration26.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ClassDeclaration26.ts(2,22): error TS1005: ';' expected. +tests/cases/compiler/ClassDeclaration26.ts(2,18): error TS1439: Variable declaration not allowed at this location. tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: ',' expected. tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected. @@ -8,8 +8,8 @@ tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or st ==== tests/cases/compiler/ClassDeclaration26.ts (5 errors) ==== class C { public const var export foo = 10; - ~~~~~~ -!!! error TS1005: ';' expected. + ~~~ +!!! error TS1439: Variable declaration not allowed at this location. var constructor() { } ~~~ diff --git a/tests/baselines/reference/anonymousModules.errors.txt b/tests/baselines/reference/anonymousModules.errors.txt index b14520a8c1c36..f91e4d0b79873 100644 --- a/tests/baselines/reference/anonymousModules.errors.txt +++ b/tests/baselines/reference/anonymousModules.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/anonymousModules.ts(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(1,8): error TS1005: ';' expected. +tests/cases/compiler/anonymousModules.ts(1,8): error TS1436: Namespace must be given a name. tests/cases/compiler/anonymousModules.ts(4,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(4,9): error TS1005: ';' expected. +tests/cases/compiler/anonymousModules.ts(4,9): error TS1436: Namespace must be given a name. tests/cases/compiler/anonymousModules.ts(10,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(10,9): error TS1005: ';' expected. +tests/cases/compiler/anonymousModules.ts(10,9): error TS1436: Namespace must be given a name. ==== tests/cases/compiler/anonymousModules.ts (6 errors) ==== @@ -11,14 +11,14 @@ tests/cases/compiler/anonymousModules.ts(10,9): error TS1005: ';' expected. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. export var foo = 1; module { ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. export var bar = 1; } @@ -28,7 +28,7 @@ tests/cases/compiler/anonymousModules.ts(10,9): error TS1005: ';' expected. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. var x = bar; } } \ No newline at end of file diff --git a/tests/baselines/reference/classUpdateTests.errors.txt b/tests/baselines/reference/classUpdateTests.errors.txt index 1d6e767aad589..27e0b3eb1c0ce 100644 --- a/tests/baselines/reference/classUpdateTests.errors.txt +++ b/tests/baselines/reference/classUpdateTests.errors.txt @@ -11,14 +11,16 @@ tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or sta tests/cases/compiler/classUpdateTests.ts(99,3): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(105,3): error TS1128: Declaration or statement expected. -tests/cases/compiler/classUpdateTests.ts(105,14): error TS1005: ';' expected. +tests/cases/compiler/classUpdateTests.ts(105,10): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/classUpdateTests.ts(105,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/classUpdateTests.ts(107,1): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(111,3): error TS1128: Declaration or statement expected. -tests/cases/compiler/classUpdateTests.ts(111,15): error TS1005: ';' expected. +tests/cases/compiler/classUpdateTests.ts(111,11): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/classUpdateTests.ts(111,15): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/classUpdateTests.ts (16 errors) ==== +==== tests/cases/compiler/classUpdateTests.ts (18 errors) ==== // // test codegen for instance properties // @@ -154,8 +156,10 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st public this.p1 = 0; // ERROR ~~~~~~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1433: Unexpected keyword or identifier. ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } } ~ @@ -166,8 +170,10 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st private this.p1 = 0; // ERROR ~~~~~~~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS1433: Unexpected keyword or identifier. ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } } ~ diff --git a/tests/baselines/reference/commonMissingSemicolons.errors.txt b/tests/baselines/reference/commonMissingSemicolons.errors.txt new file mode 100644 index 0000000000000..da9d50efe7d7c --- /dev/null +++ b/tests/baselines/reference/commonMissingSemicolons.errors.txt @@ -0,0 +1,259 @@ +tests/cases/compiler/commonMissingSemicolons.ts(2,1): error TS1434: Unknown keyword or identifier. Did you mean 'async'? +tests/cases/compiler/commonMissingSemicolons.ts(2,1): error TS2304: Cannot find name 'asynd'. +tests/cases/compiler/commonMissingSemicolons.ts(3,1): error TS1434: Unknown keyword or identifier. Did you mean 'async'? +tests/cases/compiler/commonMissingSemicolons.ts(3,1): error TS2304: Cannot find name 'sasync'. +tests/cases/compiler/commonMissingSemicolons.ts(8,23): error TS2304: Cannot find name 'asyncd'. +tests/cases/compiler/commonMissingSemicolons.ts(8,33): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(11,1): error TS1434: Unknown keyword or identifier. Did you mean 'class'? +tests/cases/compiler/commonMissingSemicolons.ts(11,1): error TS2304: Cannot find name 'clasd'. +tests/cases/compiler/commonMissingSemicolons.ts(11,7): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(11,7): error TS2552: Cannot find name 'MyClass2'. Did you mean 'MyClass1'? +tests/cases/compiler/commonMissingSemicolons.ts(12,1): error TS1434: Unknown keyword or identifier. Did you mean 'class'? +tests/cases/compiler/commonMissingSemicolons.ts(12,1): error TS2304: Cannot find name 'classs'. +tests/cases/compiler/commonMissingSemicolons.ts(12,8): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(12,8): error TS2552: Cannot find name 'MyClass3'. Did you mean 'MyClass1'? +tests/cases/compiler/commonMissingSemicolons.ts(15,1): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(15,1): error TS2304: Cannot find name 'consd'. +tests/cases/compiler/commonMissingSemicolons.ts(15,7): error TS2552: Cannot find name 'myConst2'. Did you mean 'myConst1'? +tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS2304: Cannot find name 'constd'. +tests/cases/compiler/commonMissingSemicolons.ts(16,8): error TS2304: Cannot find name 'myConst3'. +tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS2304: Cannot find name 'declared'. +tests/cases/compiler/commonMissingSemicolons.ts(20,1): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(20,1): error TS2304: Cannot find name 'declare'. +tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS2304: Cannot find name 'constd'. +tests/cases/compiler/commonMissingSemicolons.ts(21,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +tests/cases/compiler/commonMissingSemicolons.ts(21,1): error TS2304: Cannot find name 'declared'. +tests/cases/compiler/commonMissingSemicolons.ts(21,10): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(21,10): error TS2304: Cannot find name 'constd'. +tests/cases/compiler/commonMissingSemicolons.ts(22,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare const'? +tests/cases/compiler/commonMissingSemicolons.ts(22,1): error TS2304: Cannot find name 'declareconst'. +tests/cases/compiler/commonMissingSemicolons.ts(22,14): error TS2304: Cannot find name 'myDeclareConst5'. +tests/cases/compiler/commonMissingSemicolons.ts(25,1): error TS1434: Unknown keyword or identifier. Did you mean 'function'? +tests/cases/compiler/commonMissingSemicolons.ts(25,1): error TS2304: Cannot find name 'functiond'. +tests/cases/compiler/commonMissingSemicolons.ts(25,11): error TS2304: Cannot find name 'myFunction2'. +tests/cases/compiler/commonMissingSemicolons.ts(25,25): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(26,10): error TS1359: Identifier expected. 'function' is a reserved word that cannot be used here. +tests/cases/compiler/commonMissingSemicolons.ts(26,18): error TS1003: Identifier expected. +tests/cases/compiler/commonMissingSemicolons.ts(27,1): error TS2304: Cannot find name 'functionMyFunction'. +tests/cases/compiler/commonMissingSemicolons.ts(30,1): error TS1434: Unknown keyword or identifier. Did you mean 'interface'? +tests/cases/compiler/commonMissingSemicolons.ts(30,1): error TS2304: Cannot find name 'interfaced'. +tests/cases/compiler/commonMissingSemicolons.ts(30,12): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(30,12): error TS2304: Cannot find name 'myInterface2'. +tests/cases/compiler/commonMissingSemicolons.ts(32,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. +tests/cases/compiler/commonMissingSemicolons.ts(32,11): error TS1437: Interface must be given a name. +tests/cases/compiler/commonMissingSemicolons.ts(33,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. +tests/cases/compiler/commonMissingSemicolons.ts(33,11): error TS2427: Interface name cannot be 'void'. +tests/cases/compiler/commonMissingSemicolons.ts(34,1): error TS1434: Unknown keyword or identifier. Did you mean 'interface MyInterface'? +tests/cases/compiler/commonMissingSemicolons.ts(34,1): error TS2304: Cannot find name 'interfaceMyInterface'. +tests/cases/compiler/commonMissingSemicolons.ts(38,1): error TS1434: Unknown keyword or identifier. Did you mean 'let'? +tests/cases/compiler/commonMissingSemicolons.ts(38,1): error TS2304: Cannot find name 'letd'. +tests/cases/compiler/commonMissingSemicolons.ts(38,6): error TS2304: Cannot find name 'let2'. +tests/cases/compiler/commonMissingSemicolons.ts(39,1): error TS2304: Cannot find name 'letMyLet'. +tests/cases/compiler/commonMissingSemicolons.ts(41,10): error TS1005: '=' expected. +tests/cases/compiler/commonMissingSemicolons.ts(45,1): error TS1434: Unknown keyword or identifier. Did you mean 'type'? +tests/cases/compiler/commonMissingSemicolons.ts(45,1): error TS2304: Cannot find name 'typed'. +tests/cases/compiler/commonMissingSemicolons.ts(45,7): error TS2304: Cannot find name 'type4'. +tests/cases/compiler/commonMissingSemicolons.ts(46,1): error TS1434: Unknown keyword or identifier. Did you mean 'type'? +tests/cases/compiler/commonMissingSemicolons.ts(46,1): error TS2304: Cannot find name 'typed'. +tests/cases/compiler/commonMissingSemicolons.ts(46,7): error TS2304: Cannot find name 'type5'. +tests/cases/compiler/commonMissingSemicolons.ts(46,15): error TS2693: 'type' only refers to a type, but is being used as a value here. +tests/cases/compiler/commonMissingSemicolons.ts(47,1): error TS2304: Cannot find name 'typeMyType'. +tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS1434: Unknown keyword or identifier. Did you mean 'var'? +tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS2304: Cannot find name 'vard'. +tests/cases/compiler/commonMissingSemicolons.ts(50,6): error TS2304: Cannot find name 'myVar2'. +tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find name 'varMyVar'. + + +==== tests/cases/compiler/commonMissingSemicolons.ts (67 errors) ==== + async function myAsyncFunction1() {} + asynd function myAsyncFunction2() {} + ~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'async'? + ~~~~~ +!!! error TS2304: Cannot find name 'asynd'. + sasync function myAsyncFunction3() {} + ~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'async'? + ~~~~~~ +!!! error TS2304: Cannot find name 'sasync'. + + // Arrow functions don't (yet?) parse as nicely as standalone functions. + // Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". + const myAsyncArrow1 = async () => 3; + const myAsyncArrow2 = asyncd () => 3; + ~~~~~~ +!!! error TS2304: Cannot find name 'asyncd'. + ~~ +!!! error TS1005: ';' expected. + + class MyClass1 {} + clasd MyClass2 {} + ~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'class'? + ~~~~~ +!!! error TS2304: Cannot find name 'clasd'. + ~~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~~ +!!! error TS2552: Cannot find name 'MyClass2'. Did you mean 'MyClass1'? +!!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:10:7: 'MyClass1' is declared here. + classs MyClass3 {} + ~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'class'? + ~~~~~~ +!!! error TS2304: Cannot find name 'classs'. + ~~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~~ +!!! error TS2552: Cannot find name 'MyClass3'. Did you mean 'MyClass1'? +!!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:10:7: 'MyClass1' is declared here. + + const myConst1 = 1; + consd myConst2 = 1; + ~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? + ~~~~~ +!!! error TS2304: Cannot find name 'consd'. + ~~~~~~~~ +!!! error TS2552: Cannot find name 'myConst2'. Did you mean 'myConst1'? +!!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:14:7: 'myConst1' is declared here. + constd myConst3 = 1; + ~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? + ~~~~~~ +!!! error TS2304: Cannot find name 'constd'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'myConst3'. + + declare const myDeclareConst1: 1; + declared const myDeclareConst2: 1; + ~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare'? + ~~~~~~~~ +!!! error TS2304: Cannot find name 'declared'. + declare constd myDeclareConst3: 1; + ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? + ~~~~~~ +!!! error TS2304: Cannot find name 'constd'. + declared constd myDeclareConst4: 1; + ~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare'? + ~~~~~~~~ +!!! error TS2304: Cannot find name 'declared'. + ~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? + ~~~~~~ +!!! error TS2304: Cannot find name 'constd'. + declareconst myDeclareConst5; + ~~~~~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare const'? + ~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'declareconst'. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'myDeclareConst5'. + + function myFunction1() { } + functiond myFunction2() { } + ~~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'function'? + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'functiond'. + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'myFunction2'. + ~ +!!! error TS1005: ';' expected. + function function() { } + ~~~~~~~~ +!!! error TS1359: Identifier expected. 'function' is a reserved word that cannot be used here. + ~ +!!! error TS1003: Identifier expected. + functionMyFunction; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'functionMyFunction'. + + interface myInterface1 { } + interfaced myInterface2 { } + ~~~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface'? + ~~~~~~~~~~ +!!! error TS2304: Cannot find name 'interfaced'. + ~~~~~~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'myInterface2'. + interface interface { } + interface { } + ~~~~~~~~~ +!!! error TS2693: 'interface' only refers to a type, but is being used as a value here. + ~ +!!! error TS1437: Interface must be given a name. + interface void { } + ~~~~~~~~~ +!!! error TS2693: 'interface' only refers to a type, but is being used as a value here. + ~~~~ +!!! error TS2427: Interface name cannot be 'void'. + interfaceMyInterface { } + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface MyInterface'? + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'interfaceMyInterface'. + + let let = 1; + let let1 = 1; + letd let2 = 1; + ~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'let'? + ~~~~ +!!! error TS2304: Cannot find name 'letd'. + ~~~~ +!!! error TS2304: Cannot find name 'let2'. + letMyLet; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'letMyLet'. + + type type; + ~ +!!! error TS1005: '=' expected. + type type1 = {}; + type type2 = type; + type type3 = {}; + typed type4 = {} + ~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'type'? + ~~~~~ +!!! error TS2304: Cannot find name 'typed'. + ~~~~~ +!!! error TS2304: Cannot find name 'type4'. + typed type5 = type; + ~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'type'? + ~~~~~ +!!! error TS2304: Cannot find name 'typed'. + ~~~~~ +!!! error TS2304: Cannot find name 'type5'. + ~~~~ +!!! error TS2693: 'type' only refers to a type, but is being used as a value here. + typeMyType; + ~~~~~~~~~~ +!!! error TS2304: Cannot find name 'typeMyType'. + + var myVar1 = 1; + vard myVar2 = 1; + ~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'var'? + ~~~~ +!!! error TS2304: Cannot find name 'vard'. + ~~~~~~ +!!! error TS2304: Cannot find name 'myVar2'. + varMyVar; + ~~~~~~~~ +!!! error TS2304: Cannot find name 'varMyVar'. + \ No newline at end of file diff --git a/tests/baselines/reference/commonMissingSemicolons.js b/tests/baselines/reference/commonMissingSemicolons.js new file mode 100644 index 0000000000000..875125c28d94b --- /dev/null +++ b/tests/baselines/reference/commonMissingSemicolons.js @@ -0,0 +1,164 @@ +//// [commonMissingSemicolons.ts] +async function myAsyncFunction1() {} +asynd function myAsyncFunction2() {} +sasync function myAsyncFunction3() {} + +// Arrow functions don't (yet?) parse as nicely as standalone functions. +// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". +const myAsyncArrow1 = async () => 3; +const myAsyncArrow2 = asyncd () => 3; + +class MyClass1 {} +clasd MyClass2 {} +classs MyClass3 {} + +const myConst1 = 1; +consd myConst2 = 1; +constd myConst3 = 1; + +declare const myDeclareConst1: 1; +declared const myDeclareConst2: 1; +declare constd myDeclareConst3: 1; +declared constd myDeclareConst4: 1; +declareconst myDeclareConst5; + +function myFunction1() { } +functiond myFunction2() { } +function function() { } +functionMyFunction; + +interface myInterface1 { } +interfaced myInterface2 { } +interface interface { } +interface { } +interface void { } +interfaceMyInterface { } + +let let = 1; +let let1 = 1; +letd let2 = 1; +letMyLet; + +type type; +type type1 = {}; +type type2 = type; +type type3 = {}; +typed type4 = {} +typed type5 = type; +typeMyType; + +var myVar1 = 1; +vard myVar2 = 1; +varMyVar; + + +//// [commonMissingSemicolons.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var _this = this; +function myAsyncFunction1() { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} +asynd; +function myAsyncFunction2() { } +sasync; +function myAsyncFunction3() { } +// Arrow functions don't (yet?) parse as nicely as standalone functions. +// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". +var myAsyncArrow1 = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/, 3]; +}); }); }; +var myAsyncArrow2 = asyncd(); +3; +var MyClass1 = /** @class */ (function () { + function MyClass1() { + } + return MyClass1; +}()); +clasd; +MyClass2; +{ } +classs; +MyClass3; +{ } +var myConst1 = 1; +consd; +myConst2 = 1; +constd; +myConst3 = 1; +declared; +var myDeclareConst2; +declare; +constd; +myDeclareConst3: 1; +declared; +constd; +myDeclareConst4: 1; +declareconst; +myDeclareConst5; +function myFunction1() { } +functiond; +myFunction2(); +{ } +function () { } +function () { } +functionMyFunction; +interfaced; +myInterface2; +{ } +interface; +{ } +interface; +void {}; +interfaceMyInterface; +{ } +var let = 1; +var let1 = 1; +letd; +let2 = 1; +letMyLet; +typed; +type4 = {}; +typed; +type5 = type; +typeMyType; +var myVar1 = 1; +vard; +myVar2 = 1; +varMyVar; diff --git a/tests/baselines/reference/commonMissingSemicolons.symbols b/tests/baselines/reference/commonMissingSemicolons.symbols new file mode 100644 index 0000000000000..3cdb4c4301821 --- /dev/null +++ b/tests/baselines/reference/commonMissingSemicolons.symbols @@ -0,0 +1,93 @@ +=== tests/cases/compiler/commonMissingSemicolons.ts === +async function myAsyncFunction1() {} +>myAsyncFunction1 : Symbol(myAsyncFunction1, Decl(commonMissingSemicolons.ts, 0, 0)) + +asynd function myAsyncFunction2() {} +>myAsyncFunction2 : Symbol(myAsyncFunction2, Decl(commonMissingSemicolons.ts, 1, 5)) + +sasync function myAsyncFunction3() {} +>myAsyncFunction3 : Symbol(myAsyncFunction3, Decl(commonMissingSemicolons.ts, 2, 6)) + +// Arrow functions don't (yet?) parse as nicely as standalone functions. +// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". +const myAsyncArrow1 = async () => 3; +>myAsyncArrow1 : Symbol(myAsyncArrow1, Decl(commonMissingSemicolons.ts, 6, 5)) + +const myAsyncArrow2 = asyncd () => 3; +>myAsyncArrow2 : Symbol(myAsyncArrow2, Decl(commonMissingSemicolons.ts, 7, 5)) + +class MyClass1 {} +>MyClass1 : Symbol(MyClass1, Decl(commonMissingSemicolons.ts, 7, 37)) + +clasd MyClass2 {} +classs MyClass3 {} + +const myConst1 = 1; +>myConst1 : Symbol(myConst1, Decl(commonMissingSemicolons.ts, 13, 5)) + +consd myConst2 = 1; +constd myConst3 = 1; + +declare const myDeclareConst1: 1; +>myDeclareConst1 : Symbol(myDeclareConst1, Decl(commonMissingSemicolons.ts, 17, 13)) + +declared const myDeclareConst2: 1; +>myDeclareConst2 : Symbol(myDeclareConst2, Decl(commonMissingSemicolons.ts, 18, 14)) + +declare constd myDeclareConst3: 1; +declared constd myDeclareConst4: 1; +declareconst myDeclareConst5; + +function myFunction1() { } +>myFunction1 : Symbol(myFunction1, Decl(commonMissingSemicolons.ts, 21, 29)) + +functiond myFunction2() { } +function function() { } +> : Symbol((Missing), Decl(commonMissingSemicolons.ts, 24, 27), Decl(commonMissingSemicolons.ts, 25, 8)) +> : Symbol((Missing), Decl(commonMissingSemicolons.ts, 24, 27), Decl(commonMissingSemicolons.ts, 25, 8)) + +functionMyFunction; + +interface myInterface1 { } +>myInterface1 : Symbol(myInterface1, Decl(commonMissingSemicolons.ts, 26, 19)) + +interfaced myInterface2 { } +interface interface { } +>interface : Symbol(interface, Decl(commonMissingSemicolons.ts, 29, 27)) + +interface { } +interface void { } +interfaceMyInterface { } + +let let = 1; +>let : Symbol(let, Decl(commonMissingSemicolons.ts, 35, 3)) + +let let1 = 1; +>let1 : Symbol(let1, Decl(commonMissingSemicolons.ts, 36, 3)) + +letd let2 = 1; +letMyLet; + +type type; +>type : Symbol(type, Decl(commonMissingSemicolons.ts, 38, 9)) + +type type1 = {}; +>type1 : Symbol(type1, Decl(commonMissingSemicolons.ts, 40, 10)) + +type type2 = type; +>type2 : Symbol(type2, Decl(commonMissingSemicolons.ts, 41, 16)) +>type : Symbol(type, Decl(commonMissingSemicolons.ts, 38, 9)) + +type type3 = {}; +>type3 : Symbol(type3, Decl(commonMissingSemicolons.ts, 42, 18)) + +typed type4 = {} +typed type5 = type; +typeMyType; + +var myVar1 = 1; +>myVar1 : Symbol(myVar1, Decl(commonMissingSemicolons.ts, 48, 3)) + +vard myVar2 = 1; +varMyVar; + diff --git a/tests/baselines/reference/commonMissingSemicolons.types b/tests/baselines/reference/commonMissingSemicolons.types new file mode 100644 index 0000000000000..57e4c2e51dc1b --- /dev/null +++ b/tests/baselines/reference/commonMissingSemicolons.types @@ -0,0 +1,164 @@ +=== tests/cases/compiler/commonMissingSemicolons.ts === +async function myAsyncFunction1() {} +>myAsyncFunction1 : () => Promise + +asynd function myAsyncFunction2() {} +>asynd : any +>myAsyncFunction2 : () => void + +sasync function myAsyncFunction3() {} +>sasync : any +>myAsyncFunction3 : () => void + +// Arrow functions don't (yet?) parse as nicely as standalone functions. +// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". +const myAsyncArrow1 = async () => 3; +>myAsyncArrow1 : () => Promise +>async () => 3 : () => Promise +>3 : 3 + +const myAsyncArrow2 = asyncd () => 3; +>myAsyncArrow2 : any +>asyncd () : any +>asyncd : any +>3 : 3 + +class MyClass1 {} +>MyClass1 : MyClass1 + +clasd MyClass2 {} +>clasd : any +>MyClass2 : any + +classs MyClass3 {} +>classs : any +>MyClass3 : any + +const myConst1 = 1; +>myConst1 : 1 +>1 : 1 + +consd myConst2 = 1; +>consd : any +>myConst2 = 1 : 1 +>myConst2 : any +>1 : 1 + +constd myConst3 = 1; +>constd : any +>myConst3 = 1 : 1 +>myConst3 : any +>1 : 1 + +declare const myDeclareConst1: 1; +>myDeclareConst1 : 1 + +declared const myDeclareConst2: 1; +>declared : any +>myDeclareConst2 : 1 + +declare constd myDeclareConst3: 1; +>declare : any +>constd : any +>myDeclareConst3 : any +>1 : 1 + +declared constd myDeclareConst4: 1; +>declared : any +>constd : any +>myDeclareConst4 : any +>1 : 1 + +declareconst myDeclareConst5; +>declareconst : any +>myDeclareConst5 : any + +function myFunction1() { } +>myFunction1 : () => void + +functiond myFunction2() { } +>functiond : any +>myFunction2() : any +>myFunction2 : any + +function function() { } +> : () => any +> : () => any + +functionMyFunction; +>functionMyFunction : any + +interface myInterface1 { } +interfaced myInterface2 { } +>interfaced : any +>myInterface2 : any + +interface interface { } +interface { } +>interface : any + +interface void { } +>interface : any +>void { } : undefined +>{ } : {} + +interfaceMyInterface { } +>interfaceMyInterface : any + +let let = 1; +>let : number +>1 : 1 + +let let1 = 1; +>let1 : number +>1 : 1 + +letd let2 = 1; +>letd : any +>let2 = 1 : 1 +>let2 : any +>1 : 1 + +letMyLet; +>letMyLet : any + +type type; +>type : any + +type type1 = {}; +>type1 : type1 + +type type2 = type; +>type2 : any + +type type3 = {}; +>type3 : type3 + +typed type4 = {} +>typed : any +>type4 = {} : {} +>type4 : any +>{} : {} + +typed type5 = type; +>typed : any +>type5 = type : any +>type5 : any +>type : any + +typeMyType; +>typeMyType : any + +var myVar1 = 1; +>myVar1 : number +>1 : 1 + +vard myVar2 = 1; +>vard : any +>myVar2 = 1 : 1 +>myVar2 : any +>1 : 1 + +varMyVar; +>varMyVar : any + diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt index 98b96b9b1c44e..aca7ad46e127b 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4 class C { public @dec get accessor() { return 1; } ~ -!!! error TS1005: ';' expected. +!!! error TS1435: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt index e430b4cf1eea5..3d66c6796b3e8 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4 class C { public @dec set accessor(value: number) { } ~ -!!! error TS1005: ';' expected. +!!! error TS1435: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt index 4881502a02eed..0666e5c333be7 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12) class C { public @dec method() {} ~ -!!! error TS1005: ';' expected. +!!! error TS1435: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt index 12d0efb78d78c..2333d9eee9843 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4 class C { public @dec prop; ~ -!!! error TS1005: ';' expected. +!!! error TS1435: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index fbf03bd2f231a..3c501b1bb5193 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,43 +1,18 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1005: ';' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1109: Expression expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,5): error TS2304: Cannot find name 'b'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,9): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1440: Function call not allowed at this location. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,5): error TS2304: Cannot find name 'get'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS1005: ';' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS2304: Cannot find name 'C'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,13): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS2304: Cannot find name 'set'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS1005: ';' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS2304: Cannot find name 'C'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,11): error TS2304: Cannot find name 'v'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,14): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,12): error TS2304: Cannot find name 'b'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,16): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2304: Cannot find name 'super'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1440: Function call not allowed at this location. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,12): error TS2304: Cannot find name 'get'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS1005: ';' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS2304: Cannot find name 'C'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,20): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,5): error TS1128: Declaration or statement expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,12): error TS2304: Cannot find name 'set'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS1005: ';' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS2304: Cannot find name 'C'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,18): error TS2304: Cannot find name 'v'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,21): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(31,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (37 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (12 errors) ==== // error to use super calls outside a constructor class Base { @@ -49,97 +24,47 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1005: ';' expected. +!!! error TS1440: Function call not allowed at this location. ~ -!!! error TS1109: Expression expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. b() { - ~ -!!! error TS2304: Cannot find name 'b'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { - ~~~ -!!! error TS2304: Cannot find name 'get'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'C'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { - ~~~ -!!! error TS2304: Cannot find name 'set'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'C'. - ~ -!!! error TS2304: Cannot find name 'v'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); - ~~~~~~ -!!! error TS1128: Declaration or statement expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +!!! error TS2304: Cannot find name 'super'. + ~ +!!! error TS1440: Function call not allowed at this location. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. static b() { - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS2304: Cannot find name 'b'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~ -!!! error TS2304: Cannot find name 'get'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'C'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~ -!!! error TS2304: Cannot find name 'set'. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2304: Cannot find name 'C'. - ~ -!!! error TS2304: Cannot find name 'v'. - ~ -!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } - } - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index 0c1332fa55f1a..7f75e0c1fdf2d 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -58,37 +58,35 @@ var Derived = /** @class */ (function (_super) { function Derived() { return _super !== null && _super.apply(this, arguments) || this; } + ; + Derived.prototype.b = function () { + _this = _super.call(this) || this; + }; + Object.defineProperty(Derived.prototype, "C", { + get: function () { + _this = _super.call(this) || this; + return 1; + }, + set: function (v) { + _this = _super.call(this) || this; + }, + enumerable: false, + configurable: true + }); + ; + Derived.b = function () { + _this = _super.call(this) || this; + }; + Object.defineProperty(Derived, "C", { + get: function () { + _this = _super.call(this) || this; + return 1; + }, + set: function (v) { + _this = _super.call(this) || this; + }, + enumerable: false, + configurable: true + }); return Derived; }(Base)); -(); -b(); -{ - _this = _super.call(this) || this; -} -get; -C(); -{ - _this = _super.call(this) || this; - return 1; -} -set; -C(v); -{ - _this = _super.call(this) || this; -} -a: _this = _super.call(this) || this; -b(); -{ - _this = _super.call(this) || this; -} -get; -C(); -{ - _this = _super.call(this) || this; - return 1; -} -set; -C(v); -{ - _this = _super.call(this) || this; -} diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols index 8a394e9d6593a..0d5c10321cd05 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols @@ -16,25 +16,41 @@ class Derived extends Base { >a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 6, 28)) b() { +>b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 7, 15)) + super(); } get C() { +>C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) + super(); return 1; } set C(v) { +>C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) +>v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 15, 10)) + super(); } static a: super(); +>a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 17, 5)) + static b() { +>b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 19, 22)) + super(); } static get C() { +>C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) + super(); return 1; } static set C(v) { +>C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) +>v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 27, 17)) + super(); } } diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types index 715686667de21..06098482ad3e1 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types @@ -14,21 +14,16 @@ class Derived extends Base { a: super(); >a : any ->() : any -> : any b() { ->b() : any ->b : any +>b : () => void super(); >super() : void >super : any } get C() { ->get : any ->C() : any ->C : any +>C : number super(); >super() : void @@ -38,10 +33,8 @@ class Derived extends Base { >1 : 1 } set C(v) { ->set : any ->C(v) : any ->C : any ->v : any +>C : number +>v : number super(); >super() : void @@ -50,21 +43,16 @@ class Derived extends Base { static a: super(); >a : any ->super() : void ->super : any static b() { ->b() : any ->b : any +>b : () => void super(); >super() : void >super : any } static get C() { ->get : any ->C() : any ->C : any +>C : number super(); >super() : void @@ -74,10 +62,8 @@ class Derived extends Base { >1 : 1 } static set C(v) { ->set : any ->C(v) : any ->C : any ->v : any +>C : number +>v : number super(); >super() : void diff --git a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt index aa89e2dc9977d..aa65a47f774c1 100644 --- a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt @@ -1,14 +1,14 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,10): error TS1003: Identifier expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,10): error TS1141: String literal expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,12): error TS1109: Expression expected. +tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS2304: Cannot find name 'from'. -tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,19): error TS1005: ';' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: Module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,24): error TS1005: '{' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,1): error TS1128: Declaration or statement expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,8): error TS1128: Declaration or statement expected. +tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,16): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,16): error TS2304: Cannot find name 'from'. -tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,21): error TS1005: ';' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,13): error TS1005: 'from' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,13): error TS1141: String literal expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ';' expected. @@ -28,9 +28,9 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ~ !!! error TS1109: Expression expected. ~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~ !!! error TS2304: Cannot find name 'from'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1005: ';' expected. import defaultBinding, from "es6ImportNamedImportParsingError_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export. @@ -42,9 +42,9 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ~ !!! error TS1128: Declaration or statement expected. ~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~ !!! error TS2304: Cannot find name 'from'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1005: ';' expected. import { a }, from "es6ImportNamedImportParsingError_0"; ~ !!! error TS1005: 'from' expected. diff --git a/tests/baselines/reference/extension.errors.txt b/tests/baselines/reference/extension.errors.txt index d643cd9e30bd0..88bcc1eb4dbe3 100644 --- a/tests/baselines/reference/extension.errors.txt +++ b/tests/baselines/reference/extension.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/extension.ts(10,18): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/extension.ts(16,5): error TS1128: Declaration or statement expected. +tests/cases/compiler/extension.ts(16,12): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/extension.ts(16,12): error TS2304: Cannot find name 'extension'. -tests/cases/compiler/extension.ts(16,22): error TS1005: ';' expected. tests/cases/compiler/extension.ts(16,28): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not exist on type 'C'. @@ -28,9 +28,9 @@ tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not ex ~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~~~ !!! error TS2304: Cannot find name 'extension'. - ~~~~~ -!!! error TS1005: ';' expected. ~ !!! error TS2300: Duplicate identifier 'C'. public pe:string; diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index 4d6773c90ea46..611f41c30bf0e 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -1,7 +1,7 @@ +tests/cases/compiler/externModule.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/externModule.ts(1,1): error TS2304: Cannot find name 'declare'. -tests/cases/compiler/externModule.ts(1,9): error TS1005: ';' expected. tests/cases/compiler/externModule.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/externModule.ts(1,16): error TS1005: ';' expected. +tests/cases/compiler/externModule.ts(1,16): error TS1436: Namespace must be given a name. tests/cases/compiler/externModule.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/compiler/externModule.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/compiler/externModule.ts(18,6): error TS2390: Constructor implementation is missing. @@ -17,13 +17,13 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat ==== tests/cases/compiler/externModule.ts (14 errors) ==== declare module { ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. export class XDate { public getDay():number; ~~~~~~ diff --git a/tests/baselines/reference/innerModExport1.errors.txt b/tests/baselines/reference/innerModExport1.errors.txt index 28ff80d9da53a..4d37d6c033d62 100644 --- a/tests/baselines/reference/innerModExport1.errors.txt +++ b/tests/baselines/reference/innerModExport1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/innerModExport1.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/innerModExport1.ts(5,12): error TS1005: ';' expected. +tests/cases/compiler/innerModExport1.ts(5,12): error TS1436: Namespace must be given a name. ==== tests/cases/compiler/innerModExport1.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/innerModExport1.ts(5,12): error TS1005: ';' expected. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. var non_export_var = 0; export var export_var = 1; diff --git a/tests/baselines/reference/innerModExport2.errors.txt b/tests/baselines/reference/innerModExport2.errors.txt index 6c79afcddb419..b487d510f0543 100644 --- a/tests/baselines/reference/innerModExport2.errors.txt +++ b/tests/baselines/reference/innerModExport2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/innerModExport2.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/innerModExport2.ts(5,12): error TS1005: ';' expected. +tests/cases/compiler/innerModExport2.ts(5,12): error TS1436: Namespace must be given a name. tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExportFunc' does not exist on type 'typeof Outer'. @@ -14,7 +14,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1005: ';' expected. +!!! error TS1436: Namespace must be given a name. var non_export_var = 0; export var export_var = 1; ~~~~~~~~~~ diff --git a/tests/baselines/reference/interfaceDeclaration4.errors.txt b/tests/baselines/reference/interfaceDeclaration4.errors.txt index f1838011818c0..35d4fc6bac6c4 100644 --- a/tests/baselines/reference/interfaceDeclaration4.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration4.errors.txt @@ -6,8 +6,8 @@ tests/cases/compiler/interfaceDeclaration4.ts(27,7): error TS2420: Class 'C2' in tests/cases/compiler/interfaceDeclaration4.ts(36,7): error TS2420: Class 'C3' incorrectly implements interface 'I1'. Property 'item' is missing in type 'C3' but required in type 'I1'. tests/cases/compiler/interfaceDeclaration4.ts(39,14): error TS1005: '{' expected. +tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS2304: Cannot find name 'I1'. -tests/cases/compiler/interfaceDeclaration4.ts(39,18): error TS1005: ';' expected. ==== tests/cases/compiler/interfaceDeclaration4.ts (6 errors) ==== @@ -65,7 +65,7 @@ tests/cases/compiler/interfaceDeclaration4.ts(39,18): error TS1005: ';' expected ~ !!! error TS1005: '{' expected. ~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~ !!! error TS2304: Cannot find name 'I1'. - ~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceNaming1.errors.txt b/tests/baselines/reference/interfaceNaming1.errors.txt index f328e14fb1a78..55e5a1b13218c 100644 --- a/tests/baselines/reference/interfaceNaming1.errors.txt +++ b/tests/baselines/reference/interfaceNaming1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. -tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1005: ';' expected. +tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1437: Interface must be given a name. tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. @@ -9,7 +9,7 @@ tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand sid ~~~~~~~~~ !!! error TS2693: 'interface' only refers to a type, but is being used as a value here. ~ -!!! error TS1005: ';' expected. +!!! error TS1437: Interface must be given a name. interface interface{ } interface & { } ~~~~~~~~~ diff --git a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt index 1925079095a3e..43dfaf4ad7950 100644 --- a/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt +++ b/tests/baselines/reference/interfacesWithPredefinedTypesAsNames.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(3,11): error TS2427: Interface name cannot be 'string'. tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(4,11): error TS2427: Interface name cannot be 'boolean'. tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,1): error TS2304: Cannot find name 'interface'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS1005: ';' expected. +tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS2427: Interface name cannot be 'void'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (6 errors) ==== @@ -23,4 +23,4 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine ~~~~~~~~~ !!! error TS2304: Cannot find name 'interface'. ~~~~ -!!! error TS1005: ';' expected. \ No newline at end of file +!!! error TS2427: Interface name cannot be 'void'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithAMD.errors.txt b/tests/baselines/reference/invalidSyntaxNamespaceImportWithAMD.errors.txt index 97afe586046e9..6f4e15039880f 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithAMD.errors.txt +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithAMD.errors.txt @@ -2,13 +2,12 @@ tests/cases/conformance/externalModules/1.ts(1,10): error TS1005: 'as' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1005: 'from' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1141: String literal expected. tests/cases/conformance/externalModules/1.ts(1,20): error TS1005: ';' expected. -tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ==== tests/cases/conformance/externalModules/0.ts (0 errors) ==== export class C { } -==== tests/cases/conformance/externalModules/1.ts (5 errors) ==== +==== tests/cases/conformance/externalModules/1.ts (4 errors) ==== import * from Zero from "./0" ~~~~ !!! error TS1005: 'as' expected. @@ -17,6 +16,4 @@ tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ~~~~ !!! error TS1141: String literal expected. ~~~~ -!!! error TS1005: ';' expected. - ~~~~~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.errors.txt b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.errors.txt index 97afe586046e9..6f4e15039880f 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.errors.txt +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.errors.txt @@ -2,13 +2,12 @@ tests/cases/conformance/externalModules/1.ts(1,10): error TS1005: 'as' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1005: 'from' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1141: String literal expected. tests/cases/conformance/externalModules/1.ts(1,20): error TS1005: ';' expected. -tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ==== tests/cases/conformance/externalModules/0.ts (0 errors) ==== export class C { } -==== tests/cases/conformance/externalModules/1.ts (5 errors) ==== +==== tests/cases/conformance/externalModules/1.ts (4 errors) ==== import * from Zero from "./0" ~~~~ !!! error TS1005: 'as' expected. @@ -17,6 +16,4 @@ tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ~~~~ !!! error TS1141: String literal expected. ~~~~ -!!! error TS1005: ';' expected. - ~~~~~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.errors.txt b/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.errors.txt index 97afe586046e9..6f4e15039880f 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.errors.txt +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.errors.txt @@ -2,13 +2,12 @@ tests/cases/conformance/externalModules/1.ts(1,10): error TS1005: 'as' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1005: 'from' expected. tests/cases/conformance/externalModules/1.ts(1,15): error TS1141: String literal expected. tests/cases/conformance/externalModules/1.ts(1,20): error TS1005: ';' expected. -tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ==== tests/cases/conformance/externalModules/0.ts (0 errors) ==== export class C { } -==== tests/cases/conformance/externalModules/1.ts (5 errors) ==== +==== tests/cases/conformance/externalModules/1.ts (4 errors) ==== import * from Zero from "./0" ~~~~ !!! error TS1005: 'as' expected. @@ -17,6 +16,4 @@ tests/cases/conformance/externalModules/1.ts(1,25): error TS1005: ';' expected. ~~~~ !!! error TS1141: String literal expected. ~~~~ -!!! error TS1005: ';' expected. - ~~~~~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt index bc43cd5b7763b..327e79ed1cc72 100644 --- a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt +++ b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt @@ -2,8 +2,8 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(2,17): error TS1005: ':' tests/cases/compiler/parseErrorIncorrectReturnToken.ts(4,22): error TS1005: '=>' expected. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(4,24): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,18): error TS1005: '{' expected. +tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,21): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,21): error TS2693: 'string' only refers to a type, but is being used as a value here. -tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,28): error TS1005: ';' expected. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Declaration or statement expected. @@ -27,9 +27,9 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Decl !!! error TS1005: '{' expected. !!! related TS1007 tests/cases/compiler/parseErrorIncorrectReturnToken.ts:8:9: The parser expected to find a '}' to match the '{' token here. ~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ';' expected. return n.toString(); } }; diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt index 8e48e7c1750e6..8dd896bc05327 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt @@ -5,8 +5,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/12.ts(1,2): erro tests/cases/conformance/parser/ecmascriptnext/numericSeparators/13.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/14.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/15.ts(1,5): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts(1,1): error TS2304: Cannot find name '_0'. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/17.ts(1,6): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/18.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/19.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -20,8 +20,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/25.ts(1,2): erro tests/cases/conformance/parser/ecmascriptnext/numericSeparators/26.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/27.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/28.ts(1,6): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts(1,1): error TS2304: Cannot find name '_0'. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/30.ts(1,7): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/31.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -36,8 +36,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/39.ts(1,3): erro tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,2): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/40.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/41.ts(1,6): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts(1,1): error TS2304: Cannot find name '_0'. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/43.ts(1,7): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/44.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/45.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -136,9 +136,9 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts (2 errors) ==== _0.0e0 ~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~ !!! error TS2304: Cannot find name '_0'. - ~~~~ -!!! error TS1005: ';' expected. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/17.ts (1 errors) ==== 0.0e0_ @@ -203,9 +203,9 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts (2 errors) ==== _0.0e+0 ~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~ !!! error TS2304: Cannot find name '_0'. - ~~~~~ -!!! error TS1005: ';' expected. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/30.ts (1 errors) ==== 0.0e+0_ @@ -270,9 +270,9 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts (2 errors) ==== _0.0e-0 ~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~ !!! error TS2304: Cannot find name '_0'. - ~~~~~ -!!! error TS1005: ';' expected. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/43.ts (1 errors) ==== 0.0e-0_ diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 93ac55f4c409f..421ff72306b92 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -26,13 +26,14 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,82): error T tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,84): error TS2300: Duplicate identifier '0'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,85): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,86): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,94): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,88): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,94): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,96): error TS2300: Duplicate identifier '0'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,97): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error TS2304: Cannot find name 'SeedCoords'. -==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (32 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (33 errors) ==== export class Game { private position = new DisplayPosition([), 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 0], NoMove, 0); ~~~~~~~~~~~~~~~ @@ -91,8 +92,10 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T !!! error TS1005: ';' expected. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~ !!! error TS2300: Duplicate identifier '0'. ~ diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt index 0a5ab5e26e647..0e1438ddc8b29 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,20): error TS2304: Cannot find name 'C'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1441: Missing '=' before default property value. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariabl ~ !!! error TS2304: Cannot find name 'C'. ~~~~~~~ -!!! error TS1005: ';' expected. +!!! error TS1441: Missing '=' before default property value. // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserFuzz1.errors.txt b/tests/baselines/reference/parserFuzz1.errors.txt index e11d25c48fa56..63968ac5fd24b 100644 --- a/tests/baselines/reference/parserFuzz1.errors.txt +++ b/tests/baselines/reference/parserFuzz1.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,1): error TS2304: Cannot find name 'cla'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,6): error TS2304: Cannot find name 'ss'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,9): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,3): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,3): error TS2304: Cannot find name '_'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,5): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,5): error TS1128: Declaration or statement expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): error TS1005: '{' expected. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts (6 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts (7 errors) ==== cla ' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,9): error TS2304: Cannot find name 'assign'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,16): error TS2304: Cannot find name 'context'. @@ -19,9 +19,9 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGener declare module ng { interfaceICompiledExpression { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface ICompiledExpression'? + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'interfaceICompiledExpression'. - ~ -!!! error TS1005: ';' expected. (context: any, locals?: any): any; ~ !!! error TS1005: '=>' expected. diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index ae7dac2f18c8c..2a86a63f53021 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,12): error TS1005: ';' expected. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,12): error TS1441: Missing '=' before default property value. ==== tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts (5 errors) ==== @@ -29,5 +29,5 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces a: this.foo; // error ~ -!!! error TS1005: ';' expected. +!!! error TS1441: Missing '=' before default property value. } \ No newline at end of file diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index fc5ed8ae9c97d..0afac4f6229fa 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(3,6): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(4,6): error TS2457: Type alias name cannot be 'boolean'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error TS2457: Type alias name cannot be 'string'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'. -tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS2457: Type alias name cannot be 'void'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(7,6): error TS2457: Type alias name cannot be 'object'. @@ -27,7 +27,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(7,6): error ~~~~ !!! error TS2304: Cannot find name 'type'. ~~~~ -!!! error TS1005: ';' expected. +!!! error TS2457: Type alias name cannot be 'void'. ~ !!! error TS1109: Expression expected. ~ diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 599010b436872..821542d5ea6e6 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/reservedWords2.ts(5,9): error TS2567: Enum declarations can tests/cases/compiler/reservedWords2.ts(5,10): error TS1359: Identifier expected. 'throw' is a reserved word that cannot be used here. tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected. tests/cases/compiler/reservedWords2.ts(6,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/reservedWords2.ts(6,8): error TS1005: ';' expected. +tests/cases/compiler/reservedWords2.ts(6,8): error TS2803: Namespace name cannot be 'void'. tests/cases/compiler/reservedWords2.ts(7,11): error TS2300: Duplicate identifier '(Missing)'. tests/cases/compiler/reservedWords2.ts(7,11): error TS1005: ':' expected. tests/cases/compiler/reservedWords2.ts(7,19): error TS2300: Duplicate identifier '(Missing)'. @@ -77,7 +77,7 @@ tests/cases/compiler/reservedWords2.ts(12,17): error TS1138: Parameter declarati ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~ -!!! error TS1005: ';' expected. +!!! error TS2803: Namespace name cannot be 'void'. var {while, return} = { while: 1, return: 2 }; !!! error TS2300: Duplicate identifier '(Missing)'. diff --git a/tests/baselines/reference/templateStringInModuleName.errors.txt b/tests/baselines/reference/templateStringInModuleName.errors.txt index 8b9a2a9bfa729..a8e0b74c9c9b9 100644 --- a/tests/baselines/reference/templateStringInModuleName.errors.txt +++ b/tests/baselines/reference/templateStringInModuleName.errors.txt @@ -1,32 +1,32 @@ +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,21): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS2304: Cannot find name 'declare'. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,24): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error TS1442: Template literal not allowed as a string at this position. ==== tests/cases/conformance/es6/templates/templateStringInModuleName.ts (8 errors) ==== declare module `M1` { ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - ~ -!!! error TS1005: ';' expected. + ~~~~ +!!! error TS1442: Template literal not allowed as a string at this position. } declare module `M${2}` { ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - ~ -!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS1442: Template literal not allowed as a string at this position. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt index fec19b2ec4470..38171c9b59d07 100644 --- a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt +++ b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt @@ -1,32 +1,32 @@ +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS2304: Cannot find name 'declare'. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,21): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS2304: Cannot find name 'declare'. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,24): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): error TS1442: Template literal not allowed as a string at this position. ==== tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts (8 errors) ==== declare module `M1` { ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - ~ -!!! error TS1005: ';' expected. + ~~~~ +!!! error TS1442: Template literal not allowed as a string at this position. } declare module `M${2}` { ~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - ~ -!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS1442: Template literal not allowed as a string at this position. } \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 6c726e5e6f917..3e144425f4ad3 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -87,8 +87,8 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,37): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,38): error TS1109: Expression expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,39): error TS1005: ';' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,42): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,42): error TS2693: 'number' only refers to a type, but is being used as a value here. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,49): error TS1005: ';' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,23): error TS2730: An arrow function cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,16): error TS2730: An arrow function cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(177,19): error TS2730: An arrow function cannot have a 'this' parameter. @@ -425,9 +425,9 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e ~ !!! error TS1128: Declaration or statement expected. ~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. + ~~~~~~ !!! error TS2693: 'number' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ';' expected. // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.errors.txt b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.errors.txt index 6fbdba6f2c6ce..efda692c5f4fc 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.errors.txt +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.errors.txt @@ -1,7 +1,7 @@ -file.ts(1,3): error TS1005: ';' expected. +file.ts(1,1): error TS1433: Unexpected keyword or identifier. ==== file.ts (1 errors) ==== a b - ~ -!!! error TS1005: ';' expected. \ No newline at end of file + ~ +!!! error TS1433: Unexpected keyword or identifier. \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt index 6fbdba6f2c6ce..efda692c5f4fc 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt @@ -1,7 +1,7 @@ -file.ts(1,3): error TS1005: ';' expected. +file.ts(1,1): error TS1433: Unexpected keyword or identifier. ==== file.ts (1 errors) ==== a b - ~ -!!! error TS1005: ';' expected. \ No newline at end of file + ~ +!!! error TS1433: Unexpected keyword or identifier. \ No newline at end of file diff --git a/tests/baselines/reference/typeAssertions.errors.txt b/tests/baselines/reference/typeAssertions.errors.txt index 9d10ec17fe95d..a280c8010dbbc 100644 --- a/tests/baselines/reference/typeAssertions.errors.txt +++ b/tests/baselines/reference/typeAssertions.errors.txt @@ -18,9 +18,9 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(45,2): erro tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,32): error TS2749: 'numOrStr' refers to a value, but is being used as a type here. Did you mean 'typeof numOrStr'? tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,41): error TS1005: ')' expected. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,41): error TS2304: Cannot find name 'is'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,44): error TS1005: ';' expected. +tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,44): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,44): error TS2693: 'string' only refers to a type, but is being used as a value here. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): error TS1005: ';' expected. +tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): error TS1128: Declaration or statement expected. ==== tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts (18 errors) ==== @@ -111,11 +111,11 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err ~~ !!! error TS2304: Cannot find name 'is'. ~~~~~~ -!!! error TS1005: ';' expected. +!!! error TS1433: Unexpected keyword or identifier. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ -!!! error TS1005: ';' expected. +!!! error TS1128: Declaration or statement expected. } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 443c556fe558b..f8108d2e76e2e 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -2,8 +2,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(1,7): tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2749: 'x' refers to a value, but is being used as a type here. Did you mean 'typeof x'? tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,62): error TS1005: ';' expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33): error TS2749: 'x' refers to a value, but is being used as a type here. Did you mean 'typeof x'? tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(25,33): error TS1225: Cannot find parameter 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(29,10): error TS2391: Function implementation is missing or not immediately following the declaration. @@ -37,8 +36,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,21): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,20): error TS2749: 'b' refers to a value, but is being used as a type here. Did you mean 'typeof b'? tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,25): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,27): error TS1005: ';' expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,25): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(103,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,9): error TS2322: Type 'boolean' is not assignable to type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class. @@ -48,7 +46,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,9) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(115,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,22): error TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,25): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,28): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,1): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(123,20): error TS1229: A type predicate cannot reference a rest parameter. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(128,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. @@ -68,7 +65,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,45 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54): error TS2344: Type 'number' does not satisfy the constraint 'Foo'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (56 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (53 errors) ==== class A { ~ !!! error TS2300: Duplicate identifier 'A'. @@ -95,9 +92,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~~ !!! error TS1144: '{' or ';' expected. ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1433: Unexpected keyword or identifier. return true; } @@ -242,9 +237,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~~ !!! error TS1144: '{' or ';' expected. ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1433: Unexpected keyword or identifier. return true; }; @@ -284,8 +277,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~~ !!! error TS2304: Cannot find name 'p1'. ~~ -!!! error TS1005: ';' expected. - ~ !!! error TS1005: ';' expected. } ~ diff --git a/tests/cases/compiler/commonMissingSemicolons.ts b/tests/cases/compiler/commonMissingSemicolons.ts new file mode 100644 index 0000000000000..12f1e0be585e1 --- /dev/null +++ b/tests/cases/compiler/commonMissingSemicolons.ts @@ -0,0 +1,51 @@ +async function myAsyncFunction1() {} +asynd function myAsyncFunction2() {} +sasync function myAsyncFunction3() {} + +// Arrow functions don't (yet?) parse as nicely as standalone functions. +// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". +const myAsyncArrow1 = async () => 3; +const myAsyncArrow2 = asyncd () => 3; + +class MyClass1 {} +clasd MyClass2 {} +classs MyClass3 {} + +const myConst1 = 1; +consd myConst2 = 1; +constd myConst3 = 1; + +declare const myDeclareConst1: 1; +declared const myDeclareConst2: 1; +declare constd myDeclareConst3: 1; +declared constd myDeclareConst4: 1; +declareconst myDeclareConst5; + +function myFunction1() { } +functiond myFunction2() { } +function function() { } +functionMyFunction; + +interface myInterface1 { } +interfaced myInterface2 { } +interface interface { } +interface { } +interface void { } +interfaceMyInterface { } + +let let = 1; +let let1 = 1; +letd let2 = 1; +letMyLet; + +type type; +type type1 = {}; +type type2 = type; +type type3 = {}; +typed type4 = {} +typed type5 = type; +typeMyType; + +var myVar1 = 1; +vard myVar2 = 1; +varMyVar; From 107e10d90843399e51f3187f8d85b627542822a3 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 3 Mar 2021 22:48:59 -0500 Subject: [PATCH 02/17] Don't reach into there, that's not allowed --- src/compiler/parser.ts | 7 ------- tests/baselines/reference/emitBOM.js | 8 +++++++- .../invalidUnicodeEscapeSequance3.errors.txt | 8 +++++++- .../reference/parser0_004152.errors.txt | 9 ++++++--- .../scannerUnexpectedNullCharacter1.errors.txt | Bin 811 -> 1206 bytes 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 27ef130e1143f..acdbb05ab9b64 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1541,13 +1541,6 @@ namespace ts { return; } - // Specialized diagnostics for a keyword expression are redundant if the related token is already complaining. - const lastError = lastOrUndefined(parseDiagnostics); - if (lastError && scanner.getTokenPos() < lastError.start + 2) { - parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); - return; - } - // Tagged template literals are sometimes used in places where only simple strings are allowed, e.g.: // module `M1` { // ^^^^^^^^^^^ This block is parsed as a template literal as with module`M1`. diff --git a/tests/baselines/reference/emitBOM.js b/tests/baselines/reference/emitBOM.js index 2890ba0d81dbc..2e905d95a0a87 100644 --- a/tests/baselines/reference/emitBOM.js +++ b/tests/baselines/reference/emitBOM.js @@ -2,14 +2,20 @@ // JS and d.ts output should have a BOM but not the sourcemap var x; +tests/cases/compiler/emitBOM.js(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/emitBOM.js(1,2): error TS1127: Invalid character. +tests/cases/compiler/emitBOM.js(1,2): error TS1128: Declaration or statement expected. tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character. -==== tests/cases/compiler/emitBOM.js (2 errors) ==== +==== tests/cases/compiler/emitBOM.js (4 errors) ==== // JS and d.ts output should have a BOM but not the sourcemap + ~ +!!! error TS1433: Unexpected keyword or identifier. !!! error TS1127: Invalid character. + ~ +!!! error TS1128: Declaration or statement expected. !!! error TS1127: Invalid character. var x; diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt index 45674e698b68a..9511968028ab5 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt @@ -1,13 +1,19 @@ +tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS2304: Cannot find name 'a'. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1127: Invalid character. +tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1128: Declaration or statement expected. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,3): error TS2304: Cannot find name 'u'. -==== tests/cases/compiler/invalidUnicodeEscapeSequance3.ts (3 errors) ==== +==== tests/cases/compiler/invalidUnicodeEscapeSequance3.ts (5 errors) ==== a\u ~ +!!! error TS1433: Unexpected keyword or identifier. + ~ !!! error TS2304: Cannot find name 'a'. !!! error TS1127: Invalid character. + ~ +!!! error TS1128: Declaration or statement expected. ~ !!! error TS2304: Cannot find name 'u'. \ No newline at end of file diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 421ff72306b92..0549b251001be 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -1,6 +1,7 @@ +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,13): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,28): error TS2304: Cannot find name 'DisplayPosition'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,45): error TS1137: Expression or comma expected. -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,49): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,51): error TS2300: Duplicate identifier '3'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,52): error TS1005: ';' expected. @@ -33,15 +34,17 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,97): error T tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error TS2304: Cannot find name 'SeedCoords'. -==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (33 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (34 errors) ==== export class Game { private position = new DisplayPosition([), 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 0], NoMove, 0); + ~~~~~~~~ +!!! error TS1433: Unexpected keyword or identifier. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'DisplayPosition'. ~ !!! error TS1137: Expression or comma expected. ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~ !!! error TS1005: ';' expected. ~ diff --git a/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt b/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt index 6c9e72240ca31b6cf952736ddab788c0a1a677c6..28e5a76f2169a531c257f39ce6f86998ecc7510a 100644 GIT binary patch delta 202 zcmZ3@wvBT_tcszDv9XmxXkKbXL27bIYKlU3YGrwTQHnx-kwRulYF_jnV$zzQ(Tf*l9~%trvNiy;|G66MzhHdOeX5Y7@k_BH#wFm e$E=Q*OHol#A+@LoXlh8Xp`j5mmQCKzlmh?+xkzIG delta 31 ncmdnSxteW4?Btm&5)*%)pB%{ao6%&lFSE(y{mh}0Ls*gk&VCFf From 12088e901baf03d0fc7f956ea2349965547beadc Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 23 Mar 2021 00:07:55 -0400 Subject: [PATCH 03/17] Improved error when there is already an initializer --- src/compiler/parser.ts | 10 +- .../reference/commonMissingSemicolons.js | 164 ------------------ .../reference/parser0_004152.errors.txt | 5 +- .../parserComputedPropertyName33.errors.txt | 4 +- .../cases/compiler/commonMissingSemicolons.ts | 3 + 5 files changed, 14 insertions(+), 172 deletions(-) delete mode 100644 tests/baselines/reference/commonMissingSemicolons.js diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index acdbb05ab9b64..5e6ad2813854d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1531,7 +1531,7 @@ namespace ts { "var", ]; - function parseSemicolonAfter(expression: Expression | PropertyName) { + function parseSemicolonAfter(expression: Expression | PropertyName, initializer?: Node) { // Consume the semicolon if it was explicitly provided. if (canParseSemicolon()) { if (token() === SyntaxKind.SemicolonToken) { @@ -1541,6 +1541,12 @@ namespace ts { return; } + // The only way not having a semicolon after an expression when expected shouldn't create an error + // would be if we've there's an initializer, which would indicate the initializer already has an error + if (initializer) { + return; + } + // Tagged template literals are sometimes used in places where only simple strings are allowed, e.g.: // module `M1` { // ^^^^^^^^^^^ This block is parsed as a template literal as with module`M1`. @@ -1635,7 +1641,7 @@ namespace ts { return; } - return parseSemicolonAfter(name); + return parseSemicolonAfter(name, initializer); } function getExpressionText(expression: Expression | PropertyName) { diff --git a/tests/baselines/reference/commonMissingSemicolons.js b/tests/baselines/reference/commonMissingSemicolons.js deleted file mode 100644 index 875125c28d94b..0000000000000 --- a/tests/baselines/reference/commonMissingSemicolons.js +++ /dev/null @@ -1,164 +0,0 @@ -//// [commonMissingSemicolons.ts] -async function myAsyncFunction1() {} -asynd function myAsyncFunction2() {} -sasync function myAsyncFunction3() {} - -// Arrow functions don't (yet?) parse as nicely as standalone functions. -// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". -const myAsyncArrow1 = async () => 3; -const myAsyncArrow2 = asyncd () => 3; - -class MyClass1 {} -clasd MyClass2 {} -classs MyClass3 {} - -const myConst1 = 1; -consd myConst2 = 1; -constd myConst3 = 1; - -declare const myDeclareConst1: 1; -declared const myDeclareConst2: 1; -declare constd myDeclareConst3: 1; -declared constd myDeclareConst4: 1; -declareconst myDeclareConst5; - -function myFunction1() { } -functiond myFunction2() { } -function function() { } -functionMyFunction; - -interface myInterface1 { } -interfaced myInterface2 { } -interface interface { } -interface { } -interface void { } -interfaceMyInterface { } - -let let = 1; -let let1 = 1; -letd let2 = 1; -letMyLet; - -type type; -type type1 = {}; -type type2 = type; -type type3 = {}; -typed type4 = {} -typed type5 = type; -typeMyType; - -var myVar1 = 1; -vard myVar2 = 1; -varMyVar; - - -//// [commonMissingSemicolons.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var _this = this; -function myAsyncFunction1() { - return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/]; - }); }); -} -asynd; -function myAsyncFunction2() { } -sasync; -function myAsyncFunction3() { } -// Arrow functions don't (yet?) parse as nicely as standalone functions. -// Eventually it would be good to get them the same "did you mean" for typos such as "asyncd". -var myAsyncArrow1 = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/, 3]; -}); }); }; -var myAsyncArrow2 = asyncd(); -3; -var MyClass1 = /** @class */ (function () { - function MyClass1() { - } - return MyClass1; -}()); -clasd; -MyClass2; -{ } -classs; -MyClass3; -{ } -var myConst1 = 1; -consd; -myConst2 = 1; -constd; -myConst3 = 1; -declared; -var myDeclareConst2; -declare; -constd; -myDeclareConst3: 1; -declared; -constd; -myDeclareConst4: 1; -declareconst; -myDeclareConst5; -function myFunction1() { } -functiond; -myFunction2(); -{ } -function () { } -function () { } -functionMyFunction; -interfaced; -myInterface2; -{ } -interface; -{ } -interface; -void {}; -interfaceMyInterface; -{ } -var let = 1; -var let1 = 1; -letd; -let2 = 1; -letMyLet; -typed; -type4 = {}; -typed; -type5 = type; -typeMyType; -var myVar1 = 1; -vard; -myVar2 = 1; -varMyVar; diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 0549b251001be..935e51b77dfb1 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,13): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,28): error TS2304: Cannot find name 'DisplayPosition'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,45): error TS1137: Expression or comma expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. @@ -34,11 +33,9 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,97): error T tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error TS2304: Cannot find name 'SeedCoords'. -==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (34 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts (33 errors) ==== export class Game { private position = new DisplayPosition([), 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 0], NoMove, 0); - ~~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'DisplayPosition'. ~ diff --git a/tests/baselines/reference/parserComputedPropertyName33.errors.txt b/tests/baselines/reference/parserComputedPropertyName33.errors.txt index 5ce420ceb60a6..234aa38803fdd 100644 --- a/tests/baselines/reference/parserComputedPropertyName33.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName33.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,6): error TS2304: Cannot find name 'e2'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,12): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(5,1): error TS1128: Declaration or statement expected. @@ -14,7 +14,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP ~~ !!! error TS2304: Cannot find name 'e2'. ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/cases/compiler/commonMissingSemicolons.ts b/tests/cases/compiler/commonMissingSemicolons.ts index 12f1e0be585e1..6d650bd584fce 100644 --- a/tests/cases/compiler/commonMissingSemicolons.ts +++ b/tests/cases/compiler/commonMissingSemicolons.ts @@ -1,3 +1,6 @@ +// @noEmit: true +// @noTypesAndSymbols: true + async function myAsyncFunction1() {} asynd function myAsyncFunction2() {} sasync function myAsyncFunction3() {} From 73a9852da585e3ee033ba2a4864ae689dec6dcca Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 28 Mar 2021 11:41:17 -0400 Subject: [PATCH 04/17] Specific module error message for invalid template literal strings --- src/compiler/diagnosticMessages.json | 6 +----- src/compiler/parser.ts | 6 +++--- .../reference/templateStringInModuleName.errors.txt | 8 ++++---- .../reference/templateStringInModuleNameES6.errors.txt | 8 ++++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3383a6fcda8e1..0c3215815e643 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1396,14 +1396,10 @@ "category": "Error", "code": 1441 }, - "Template literal not allowed as a string at this position.": { + "Module declaration names may only use ' or \" quoted strings.": { "category": "Error", "code": 1442 }, - "Template literal not allowed as a string at this position. Did you mean '{0}'?": { - "category": "Error", - "code": 1443 - }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5e6ad2813854d..cad5d277b4ae3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1547,11 +1547,11 @@ namespace ts { return; } - // Tagged template literals are sometimes used in places where only simple strings are allowed, e.g.: + // Tagged template literals are sometimes used in places where only simple strings are allowed, i.e.: // module `M1` { - // ^^^^^^^^^^^ This block is parsed as a template literal as with module`M1`. + // ^^^^^^^^^^^ This block is parsed as a template literal like module`M1`. if (isTaggedTemplateExpression(expression)) { - parseErrorAt(skipTrivia(sourceText, expression.template.pos), expression.template.end, Diagnostics.Template_literal_not_allowed_as_a_string_at_this_position); + parseErrorAt(skipTrivia(sourceText, expression.template.pos), expression.template.end, Diagnostics.Module_declaration_names_may_only_use_or_quoted_strings); return; } diff --git a/tests/baselines/reference/templateStringInModuleName.errors.txt b/tests/baselines/reference/templateStringInModuleName.errors.txt index a8e0b74c9c9b9..50210bb1cd688 100644 --- a/tests/baselines/reference/templateStringInModuleName.errors.txt +++ b/tests/baselines/reference/templateStringInModuleName.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,16): error TS1442: Module declaration names may only use ' or " quoted strings. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error TS1442: Module declaration names may only use ' or " quoted strings. ==== tests/cases/conformance/es6/templates/templateStringInModuleName.ts (8 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~ -!!! error TS1442: Template literal not allowed as a string at this position. +!!! error TS1442: Module declaration names may only use ' or " quoted strings. } declare module `M${2}` { @@ -28,5 +28,5 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~~~~ -!!! error TS1442: Template literal not allowed as a string at this position. +!!! error TS1442: Module declaration names may only use ' or " quoted strings. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt index 38171c9b59d07..b31affa88f151 100644 --- a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt +++ b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,16): error TS1442: Module declaration names may only use ' or " quoted strings. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): error TS1442: Template literal not allowed as a string at this position. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): error TS1442: Module declaration names may only use ' or " quoted strings. ==== tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts (8 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): er ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~ -!!! error TS1442: Template literal not allowed as a string at this position. +!!! error TS1442: Module declaration names may only use ' or " quoted strings. } declare module `M${2}` { @@ -28,5 +28,5 @@ tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): er ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~~~~ -!!! error TS1442: Template literal not allowed as a string at this position. +!!! error TS1442: Module declaration names may only use ' or " quoted strings. } \ No newline at end of file From cc70a1b6c4c5c53616067b572b13496b1395f49a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 28 Mar 2021 12:02:16 -0400 Subject: [PATCH 05/17] Skip 'unexpected keyword or identifier' diagnostics for declare nodes --- src/compiler/parser.ts | 4 ++++ .../reference/commonMissingSemicolons.errors.txt | 5 +---- .../reference/templateStringInModuleName.errors.txt | 8 +------- .../reference/templateStringInModuleNameES6.errors.txt | 8 +------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index cad5d277b4ae3..8fe948fd0b4e4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1572,6 +1572,10 @@ namespace ts { parseErrorAt(pos, expression.end, Diagnostics.Variable_declaration_not_allowed_at_this_location); return; + case "declare": + // If a declared node failed to parse, it would have emitted a diagnostic already. + return; + case "interface": parseErrorForExpectedName(scanner.getTokenText(), "{", Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0); return; diff --git a/tests/baselines/reference/commonMissingSemicolons.errors.txt b/tests/baselines/reference/commonMissingSemicolons.errors.txt index da9d50efe7d7c..3c53b3c3095c9 100644 --- a/tests/baselines/reference/commonMissingSemicolons.errors.txt +++ b/tests/baselines/reference/commonMissingSemicolons.errors.txt @@ -20,7 +20,6 @@ tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS2304: Cannot find tests/cases/compiler/commonMissingSemicolons.ts(16,8): error TS2304: Cannot find name 'myConst3'. tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare'? tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS2304: Cannot find name 'declared'. -tests/cases/compiler/commonMissingSemicolons.ts(20,1): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/commonMissingSemicolons.ts(20,1): error TS2304: Cannot find name 'declare'. tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS1434: Unknown keyword or identifier. Did you mean 'const'? tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS2304: Cannot find name 'constd'. @@ -67,7 +66,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(50,6): error TS2304: Cannot find tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find name 'varMyVar'. -==== tests/cases/compiler/commonMissingSemicolons.ts (67 errors) ==== +==== tests/cases/compiler/commonMissingSemicolons.ts (66 errors) ==== async function myAsyncFunction1() {} asynd function myAsyncFunction2() {} ~~~~~ @@ -136,8 +135,6 @@ tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find !!! error TS2304: Cannot find name 'declared'. declare constd myDeclareConst3: 1; ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? diff --git a/tests/baselines/reference/templateStringInModuleName.errors.txt b/tests/baselines/reference/templateStringInModuleName.errors.txt index 50210bb1cd688..2550409c799a1 100644 --- a/tests/baselines/reference/templateStringInModuleName.errors.txt +++ b/tests/baselines/reference/templateStringInModuleName.errors.txt @@ -1,18 +1,14 @@ -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,16): error TS1442: Module declaration names may only use ' or " quoted strings. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error TS1442: Module declaration names may only use ' or " quoted strings. -==== tests/cases/conformance/es6/templates/templateStringInModuleName.ts (8 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringInModuleName.ts (6 errors) ==== declare module `M1` { ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -22,8 +18,6 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,16): error declare module `M${2}` { ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. diff --git a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt index b31affa88f151..33e9abc4c31c2 100644 --- a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt +++ b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt @@ -1,18 +1,14 @@ -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,16): error TS1442: Module declaration names may only use ' or " quoted strings. -tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS1433: Unexpected keyword or identifier. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): error TS1442: Module declaration names may only use ' or " quoted strings. -==== tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts (8 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts (6 errors) ==== declare module `M1` { ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -22,8 +18,6 @@ tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,16): er declare module `M${2}` { ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. From 23e0acbc911487765bf64109c10538bf1166524b Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 28 Mar 2021 13:45:43 -0400 Subject: [PATCH 06/17] Improve error for function calls in type positions --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 3 ++- ...rivedClassSuperCallsInNonConstructorMembers.errors.txt | 8 ++++---- tests/baselines/reference/externModule.errors.txt | 5 +---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0c3215815e643..a5c8abfd09d85 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1388,7 +1388,7 @@ "category": "Error", "code": 1439 }, - "Function call not allowed at this location.": { + "Function call is not a type annotation.": { "category": "Error", "code": 1440 }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8fe948fd0b4e4..e73b409e6e453 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1598,6 +1598,7 @@ namespace ts { const suggestion = getSpellingSuggestion(expressionText, commonKeywords, n => n) || getSpaceSuggestion(expressionText); if (suggestion) { parseErrorAt(pos, expression.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); + return; } // We know this is a slightly more precise case than a missing expected semicolon. @@ -1630,7 +1631,7 @@ namespace ts { return; case "(": - parseErrorAtCurrentToken(Diagnostics.Function_call_not_allowed_at_this_location); + parseErrorAtCurrentToken(Diagnostics.Function_call_is_not_a_type_annotation); nextToken(); return; } diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index 3c501b1bb5193..18d78664e99c7 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1440: Function call not allowed at this location. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1440: Function call is not a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1440: Function call not allowed at this location. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1440: Function call is not a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. @@ -24,7 +24,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1440: Function call not allowed at this location. +!!! error TS1440: Function call is not a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. b() { @@ -48,7 +48,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1440: Function call not allowed at this location. +!!! error TS1440: Function call is not a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. static b() { diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index 611f41c30bf0e..6b8eedd16e9e1 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/externModule.ts(1,1): error TS1433: Unexpected keyword or identifier. tests/cases/compiler/externModule.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/compiler/externModule.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. tests/cases/compiler/externModule.ts(1,16): error TS1436: Namespace must be given a name. @@ -14,11 +13,9 @@ tests/cases/compiler/externModule.ts(36,7): error TS2552: Cannot find name 'XDat tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -==== tests/cases/compiler/externModule.ts (14 errors) ==== +==== tests/cases/compiler/externModule.ts (13 errors) ==== declare module { ~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. - ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. From 05e8d0ffc2c64cb55a8e8665d30084265f08da3d Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 6 Apr 2021 23:49:33 -0400 Subject: [PATCH 07/17] Switch class properties to old diagnostic --- src/compiler/diagnosticMessages.json | 4 ++ src/compiler/parser.ts | 5 +- .../commonMissingSemicolons.errors.txt | 50 ++++++++++++++++++- .../parserComputedPropertyName33.errors.txt | 4 +- .../cases/compiler/commonMissingSemicolons.ts | 23 +++++++++ 5 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7ff579205dd44..b595850ec5188 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1400,6 +1400,10 @@ "category": "Error", "code": 1442 }, + "A new function block or object is not allowed after this class member value. Is a semicolon missing after the member value?": { + "category": "Error", + "code": 1443 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 88c53889b8ba0..b495541fabbb0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2557,7 +2557,10 @@ namespace ts { case ParsingContext.SwitchClauseStatements: return parseErrorAtCurrentToken(Diagnostics.Statement_expected); case ParsingContext.RestProperties: // fallthrough case ParsingContext.TypeMembers: return parseErrorAtCurrentToken(Diagnostics.Property_or_signature_expected); - case ParsingContext.ClassMembers: return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case ParsingContext.ClassMembers: + return token() === SyntaxKind.OpenBraceToken + ? parseErrorAtCurrentToken(Diagnostics._0_expected, ";") + : parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); case ParsingContext.EnumMembers: return parseErrorAtCurrentToken(Diagnostics.Enum_member_expected); case ParsingContext.HeritageClauseElement: return parseErrorAtCurrentToken(Diagnostics.Expression_expected); case ParsingContext.VariableDeclarations: diff --git a/tests/baselines/reference/commonMissingSemicolons.errors.txt b/tests/baselines/reference/commonMissingSemicolons.errors.txt index 3c53b3c3095c9..693a0462fb164 100644 --- a/tests/baselines/reference/commonMissingSemicolons.errors.txt +++ b/tests/baselines/reference/commonMissingSemicolons.errors.txt @@ -64,9 +64,17 @@ tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS1434: Unknown key tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS2304: Cannot find name 'vard'. tests/cases/compiler/commonMissingSemicolons.ts(50,6): error TS2304: Cannot find name 'myVar2'. tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find name 'varMyVar'. +tests/cases/compiler/commonMissingSemicolons.ts(55,3): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(56,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(60,3): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(61,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(65,13): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(66,3): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(70,13): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(73,3): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/commonMissingSemicolons.ts (66 errors) ==== +==== tests/cases/compiler/commonMissingSemicolons.ts (74 errors) ==== async function myAsyncFunction1() {} asynd function myAsyncFunction2() {} ~~~~~ @@ -253,4 +261,42 @@ tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find varMyVar; ~~~~~~~~ !!! error TS2304: Cannot find name 'varMyVar'. - \ No newline at end of file + + class NoSemicolonClassA { + ['a'] = 0 + {} + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. + + class NoSemicolonClassB { + ['a'] = 0; + {} + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. + + class NoSemicolonClassC { + ['a'] = 0 + ['b']() {} + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. + + class NoSemicolonClassD { + ['a'] = 0 + ['b']() { + ~ +!!! error TS1005: ';' expected. + c: true + } + } + ~ +!!! error TS1128: Declaration or statement expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName33.errors.txt b/tests/baselines/reference/parserComputedPropertyName33.errors.txt index 234aa38803fdd..5ce420ceb60a6 100644 --- a/tests/baselines/reference/parserComputedPropertyName33.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName33.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,6): error TS2304: Cannot find name 'e2'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(4,12): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts(5,1): error TS1128: Declaration or statement expected. @@ -14,7 +14,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP ~~ !!! error TS2304: Cannot find name 'e2'. ~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +!!! error TS1005: ';' expected. } ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/cases/compiler/commonMissingSemicolons.ts b/tests/cases/compiler/commonMissingSemicolons.ts index 6d650bd584fce..6b43e502c7817 100644 --- a/tests/cases/compiler/commonMissingSemicolons.ts +++ b/tests/cases/compiler/commonMissingSemicolons.ts @@ -52,3 +52,26 @@ typeMyType; var myVar1 = 1; vard myVar2 = 1; varMyVar; + +class NoSemicolonClassA { + ['a'] = 0 + {} +} + +class NoSemicolonClassB { + ['a'] = 0; + {} +} + +class NoSemicolonClassC { + ['a'] = 0 + ['b']() {} + } + +class NoSemicolonClassD { + ['a'] = 0 + ['b']() { + c: true + } + } + \ No newline at end of file From 972da9342f74a55acf101de020cef71d567f0ee1 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 11 Apr 2021 14:42:56 -0400 Subject: [PATCH 08/17] Corrected errors in class members and reused existing textToKeywordObj map --- src/compiler/diagnosticMessages.json | 4 -- src/compiler/parser.ts | 39 ++++++------- src/compiler/scanner.ts | 3 +- .../commonMissingSemicolons.errors.txt | 57 +++++++++++-------- .../cases/compiler/commonMissingSemicolons.ts | 24 ++++---- 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 76e116212d96c..32f3a260d5eec 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1400,10 +1400,6 @@ "category": "Error", "code": 1442 }, - "A new function block or object is not allowed after this class member value. Is a semicolon missing after the member value?": { - "category": "Error", - "code": 1443 - }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 74d0d073b730b..5b6157a3a0b4e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1537,20 +1537,9 @@ namespace ts { return false; } - const commonKeywords = [ - "async", - "class", - "const", - "declare", - "export", - "function", - "interface", - "let", - "type", - "var", - ]; - - function parseSemicolonAfter(expression: Expression | PropertyName, initializer?: Node) { + const viableKeywordSuggestions = Object.keys(textToKeywordObj).filter(keyword => keyword.length > 2); + + function parseSemicolonAfter(parentKind: SyntaxKind, expression: Expression | PropertyName, initializer?: Node) { // Consume the semicolon if it was explicitly provided. if (canParseSemicolon()) { if (token() === SyntaxKind.SemicolonToken) { @@ -1561,8 +1550,14 @@ namespace ts { } // The only way not having a semicolon after an expression when expected shouldn't create an error - // would be if we've there's an initializer, which would indicate the initializer already has an error + // would be if there's an initializer, which would indicate the initializer already has an error... if (initializer) { + // ...unless we're parsing property declarations, in which case we can know that the initializer + // was fine but we included something invalid immediately after it + if (token() === SyntaxKind.OpenBraceToken && parentKind === SyntaxKind.PropertyDeclaration) { + parseErrorAtCurrentToken(Diagnostics._0_expected, ";"); + } + return; } @@ -1614,7 +1609,7 @@ namespace ts { } // The user alternately might have misspelled or forgotten to add a space after a common keyword. - const suggestion = getSpellingSuggestion(expressionText, commonKeywords, n => n) || getSpaceSuggestion(expressionText); + const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, n => n) || getSpaceSuggestion(expressionText); if (suggestion) { parseErrorAt(pos, expression.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); return; @@ -1634,7 +1629,7 @@ namespace ts { } function getSpaceSuggestion(expressionText: string) { - for (const keyword of commonKeywords) { + for (const keyword of viableKeywordSuggestions) { if (expressionText.length > keyword.length + 2 && startsWith(expressionText, keyword)) { return `${keyword} ${expressionText.slice(keyword.length)}`; } @@ -1665,7 +1660,7 @@ namespace ts { return; } - return parseSemicolonAfter(name, initializer); + return parseSemicolonAfter(SyntaxKind.PropertyDeclaration, name, initializer); } function getExpressionText(expression: Expression | PropertyName) { @@ -2575,9 +2570,7 @@ namespace ts { case ParsingContext.RestProperties: // fallthrough case ParsingContext.TypeMembers: return parseErrorAtCurrentToken(Diagnostics.Property_or_signature_expected); case ParsingContext.ClassMembers: - return token() === SyntaxKind.OpenBraceToken - ? parseErrorAtCurrentToken(Diagnostics._0_expected, ";") - : parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); case ParsingContext.EnumMembers: return parseErrorAtCurrentToken(Diagnostics.Enum_member_expected); case ParsingContext.HeritageClauseElement: return parseErrorAtCurrentToken(Diagnostics.Expression_expected); case ParsingContext.VariableDeclarations: @@ -5964,7 +5957,7 @@ namespace ts { identifierCount++; expression = finishNode(factory.createIdentifier(""), getNodePos()); } - parseSemicolonAfter(expression); + parseSemicolonAfter(SyntaxKind.Block, expression); return finishNode(factory.createThrowStatement(expression), pos); } @@ -6025,7 +6018,7 @@ namespace ts { node = factory.createLabeledStatement(expression, parseStatement()); } else { - parseSemicolonAfter(expression); + parseSemicolonAfter(SyntaxKind.Block, expression); node = factory.createExpressionStatement(expression); if (hasParen) { // do not parse the same jsdoc twice diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 79b414d3d4c09..38b5f34d84c76 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -76,7 +76,8 @@ namespace ts { tryScan(callback: () => T): T; } - const textToKeywordObj: MapLike = { + /** @internal */ + export const textToKeywordObj: MapLike = { abstract: SyntaxKind.AbstractKeyword, any: SyntaxKind.AnyKeyword, as: SyntaxKind.AsKeyword, diff --git a/tests/baselines/reference/commonMissingSemicolons.errors.txt b/tests/baselines/reference/commonMissingSemicolons.errors.txt index 693a0462fb164..5e822a3127021 100644 --- a/tests/baselines/reference/commonMissingSemicolons.errors.txt +++ b/tests/baselines/reference/commonMissingSemicolons.errors.txt @@ -64,17 +64,19 @@ tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS1434: Unknown key tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS2304: Cannot find name 'vard'. tests/cases/compiler/commonMissingSemicolons.ts(50,6): error TS2304: Cannot find name 'myVar2'. tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find name 'varMyVar'. -tests/cases/compiler/commonMissingSemicolons.ts(55,3): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(55,3): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/commonMissingSemicolons.ts(56,1): error TS1128: Declaration or statement expected. -tests/cases/compiler/commonMissingSemicolons.ts(60,3): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(60,3): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/commonMissingSemicolons.ts(61,1): error TS1128: Declaration or statement expected. -tests/cases/compiler/commonMissingSemicolons.ts(65,13): error TS1005: ';' expected. -tests/cases/compiler/commonMissingSemicolons.ts(66,3): error TS1128: Declaration or statement expected. -tests/cases/compiler/commonMissingSemicolons.ts(70,13): error TS1005: ';' expected. -tests/cases/compiler/commonMissingSemicolons.ts(73,3): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(65,3): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/compiler/commonMissingSemicolons.ts(66,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(70,11): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(71,1): error TS1128: Declaration or statement expected. +tests/cases/compiler/commonMissingSemicolons.ts(75,11): error TS1005: ';' expected. +tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/commonMissingSemicolons.ts (74 errors) ==== +==== tests/cases/compiler/commonMissingSemicolons.ts (76 errors) ==== async function myAsyncFunction1() {} asynd function myAsyncFunction2() {} ~~~~~ @@ -266,37 +268,46 @@ tests/cases/compiler/commonMissingSemicolons.ts(73,3): error TS1128: Declaration ['a'] = 0 {} ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } ~ !!! error TS1128: Declaration or statement expected. class NoSemicolonClassB { - ['a'] = 0; + ['a'] = 0 {} ~ -!!! error TS1005: ';' expected. +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } ~ !!! error TS1128: Declaration or statement expected. class NoSemicolonClassC { - ['a'] = 0 - ['b']() {} - ~ -!!! error TS1005: ';' expected. - } + ['a'] = 0; + {} ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + } + ~ !!! error TS1128: Declaration or statement expected. - + class NoSemicolonClassD { - ['a'] = 0 - ['b']() { - ~ + ['a'] = 0 + ['b']() {} + ~ +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. + + class NoSemicolonClassE { + ['a'] = 0 + ['b']() { + ~ !!! error TS1005: ';' expected. - c: true - } + c: true } - ~ + } + ~ !!! error TS1128: Declaration or statement expected. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/cases/compiler/commonMissingSemicolons.ts b/tests/cases/compiler/commonMissingSemicolons.ts index 6b43e502c7817..197177c9f4bb5 100644 --- a/tests/cases/compiler/commonMissingSemicolons.ts +++ b/tests/cases/compiler/commonMissingSemicolons.ts @@ -59,19 +59,23 @@ class NoSemicolonClassA { } class NoSemicolonClassB { - ['a'] = 0; + ['a'] = 0 {} } class NoSemicolonClassC { - ['a'] = 0 - ['b']() {} - } - + ['a'] = 0; + {} +} + class NoSemicolonClassD { - ['a'] = 0 - ['b']() { - c: true - } + ['a'] = 0 + ['b']() {} +} + +class NoSemicolonClassE { + ['a'] = 0 + ['b']() { + c: true } - \ No newline at end of file +} From 5a0804b2cb174aadf41c260ae244d4ee5238e1d4 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 11 Apr 2021 15:37:25 -0400 Subject: [PATCH 09/17] Corrected more baselines from the merge --- .../reference/ClassDeclaration26.errors.txt | 4 +- .../reference/anonymousModules.errors.txt | 12 +-- .../reference/classUpdateTests.errors.txt | 8 +- .../commonMissingSemicolons.errors.txt | 88 +++++++++--------- .../decoratorOnClassAccessor3.errors.txt | 4 +- .../decoratorOnClassAccessor6.errors.txt | 4 +- .../decoratorOnClassMethod3.errors.txt | 4 +- .../decoratorOnClassProperty3.errors.txt | 4 +- ...perCallsInNonConstructorMembers.errors.txt | 8 +- tests/baselines/reference/emitBOM.js | 4 +- ...s6ImportNamedImportParsingError.errors.txt | 8 +- .../baselines/reference/extension.errors.txt | 4 +- .../reference/externModule.errors.txt | 4 +- .../reference/innerModExport1.errors.txt | 4 +- .../reference/innerModExport2.errors.txt | 4 +- .../interfaceDeclaration4.errors.txt | 4 +- .../reference/interfaceNaming1.errors.txt | 4 +- .../invalidUnicodeEscapeSequance3.errors.txt | 4 +- .../parseErrorIncorrectReturnToken.errors.txt | 4 +- ...mericSeparators.decmialNegative.errors.txt | 12 +-- .../reference/parser0_004152.errors.txt | 4 +- ...overy_IncompleteMemberVariable2.errors.txt | 4 +- .../reference/parserFuzz1.errors.txt | 4 +- .../parserSkippedTokens16.errors.txt | 4 +- .../parserUnterminatedGeneric2.errors.txt | 4 +- ...vateInstanceMemberAccessibility.errors.txt | 4 +- .../reference/reservedWords2.errors.txt | 4 +- ...scannerUnexpectedNullCharacter1.errors.txt | Bin 1206 -> 1206 bytes .../templateStringInModuleName.errors.txt | 8 +- .../templateStringInModuleNameES6.errors.txt | 8 +- .../thisTypeInFunctionsNegative.errors.txt | 4 +- ... expected syntactic diagnostics.errors.txt | 4 +- ...tactic diagnostics.oldTranspile.errors.txt | 4 +- .../reference/typeAssertions.errors.txt | 4 +- .../typeGuardFunctionErrors.errors.txt | 8 +- 35 files changed, 130 insertions(+), 130 deletions(-) diff --git a/tests/baselines/reference/ClassDeclaration26.errors.txt b/tests/baselines/reference/ClassDeclaration26.errors.txt index 1618901306ea7..4b7534741b1f2 100644 --- a/tests/baselines/reference/ClassDeclaration26.errors.txt +++ b/tests/baselines/reference/ClassDeclaration26.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ClassDeclaration26.ts(2,18): error TS1439: Variable declaration not allowed at this location. +tests/cases/compiler/ClassDeclaration26.ts(2,18): error TS1440: Variable declaration not allowed at this location. tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: ',' expected. tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or st class C { public const var export foo = 10; ~~~ -!!! error TS1439: Variable declaration not allowed at this location. +!!! error TS1440: Variable declaration not allowed at this location. var constructor() { } ~~~ diff --git a/tests/baselines/reference/anonymousModules.errors.txt b/tests/baselines/reference/anonymousModules.errors.txt index f91e4d0b79873..419eb5d3d3e9b 100644 --- a/tests/baselines/reference/anonymousModules.errors.txt +++ b/tests/baselines/reference/anonymousModules.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/anonymousModules.ts(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(1,8): error TS1436: Namespace must be given a name. +tests/cases/compiler/anonymousModules.ts(1,8): error TS1437: Namespace must be given a name. tests/cases/compiler/anonymousModules.ts(4,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(4,9): error TS1436: Namespace must be given a name. +tests/cases/compiler/anonymousModules.ts(4,9): error TS1437: Namespace must be given a name. tests/cases/compiler/anonymousModules.ts(10,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/anonymousModules.ts(10,9): error TS1436: Namespace must be given a name. +tests/cases/compiler/anonymousModules.ts(10,9): error TS1437: Namespace must be given a name. ==== tests/cases/compiler/anonymousModules.ts (6 errors) ==== @@ -11,14 +11,14 @@ tests/cases/compiler/anonymousModules.ts(10,9): error TS1436: Namespace must be ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. export var foo = 1; module { ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. export var bar = 1; } @@ -28,7 +28,7 @@ tests/cases/compiler/anonymousModules.ts(10,9): error TS1436: Namespace must be ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. var x = bar; } } \ No newline at end of file diff --git a/tests/baselines/reference/classUpdateTests.errors.txt b/tests/baselines/reference/classUpdateTests.errors.txt index 27e0b3eb1c0ce..4a10022982838 100644 --- a/tests/baselines/reference/classUpdateTests.errors.txt +++ b/tests/baselines/reference/classUpdateTests.errors.txt @@ -11,11 +11,11 @@ tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or sta tests/cases/compiler/classUpdateTests.ts(99,3): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(105,3): error TS1128: Declaration or statement expected. -tests/cases/compiler/classUpdateTests.ts(105,10): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/classUpdateTests.ts(105,10): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/classUpdateTests.ts(105,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/classUpdateTests.ts(107,1): error TS1128: Declaration or statement expected. tests/cases/compiler/classUpdateTests.ts(111,3): error TS1128: Declaration or statement expected. -tests/cases/compiler/classUpdateTests.ts(111,11): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/classUpdateTests.ts(111,11): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/classUpdateTests.ts(111,15): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected. @@ -157,7 +157,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st ~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } @@ -171,7 +171,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st ~~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } diff --git a/tests/baselines/reference/commonMissingSemicolons.errors.txt b/tests/baselines/reference/commonMissingSemicolons.errors.txt index 5e822a3127021..15df55ec4aa9a 100644 --- a/tests/baselines/reference/commonMissingSemicolons.errors.txt +++ b/tests/baselines/reference/commonMissingSemicolons.errors.txt @@ -1,66 +1,66 @@ -tests/cases/compiler/commonMissingSemicolons.ts(2,1): error TS1434: Unknown keyword or identifier. Did you mean 'async'? +tests/cases/compiler/commonMissingSemicolons.ts(2,1): error TS1435: Unknown keyword or identifier. Did you mean 'async'? tests/cases/compiler/commonMissingSemicolons.ts(2,1): error TS2304: Cannot find name 'asynd'. -tests/cases/compiler/commonMissingSemicolons.ts(3,1): error TS1434: Unknown keyword or identifier. Did you mean 'async'? +tests/cases/compiler/commonMissingSemicolons.ts(3,1): error TS1435: Unknown keyword or identifier. Did you mean 'async'? tests/cases/compiler/commonMissingSemicolons.ts(3,1): error TS2304: Cannot find name 'sasync'. tests/cases/compiler/commonMissingSemicolons.ts(8,23): error TS2304: Cannot find name 'asyncd'. tests/cases/compiler/commonMissingSemicolons.ts(8,33): error TS1005: ';' expected. -tests/cases/compiler/commonMissingSemicolons.ts(11,1): error TS1434: Unknown keyword or identifier. Did you mean 'class'? +tests/cases/compiler/commonMissingSemicolons.ts(11,1): error TS1435: Unknown keyword or identifier. Did you mean 'class'? tests/cases/compiler/commonMissingSemicolons.ts(11,1): error TS2304: Cannot find name 'clasd'. -tests/cases/compiler/commonMissingSemicolons.ts(11,7): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(11,7): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/commonMissingSemicolons.ts(11,7): error TS2552: Cannot find name 'MyClass2'. Did you mean 'MyClass1'? -tests/cases/compiler/commonMissingSemicolons.ts(12,1): error TS1434: Unknown keyword or identifier. Did you mean 'class'? +tests/cases/compiler/commonMissingSemicolons.ts(12,1): error TS1435: Unknown keyword or identifier. Did you mean 'class'? tests/cases/compiler/commonMissingSemicolons.ts(12,1): error TS2304: Cannot find name 'classs'. -tests/cases/compiler/commonMissingSemicolons.ts(12,8): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(12,8): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/commonMissingSemicolons.ts(12,8): error TS2552: Cannot find name 'MyClass3'. Did you mean 'MyClass1'? -tests/cases/compiler/commonMissingSemicolons.ts(15,1): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(15,1): error TS1435: Unknown keyword or identifier. Did you mean 'const'? tests/cases/compiler/commonMissingSemicolons.ts(15,1): error TS2304: Cannot find name 'consd'. tests/cases/compiler/commonMissingSemicolons.ts(15,7): error TS2552: Cannot find name 'myConst2'. Did you mean 'myConst1'? -tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS1435: Unknown keyword or identifier. Did you mean 'const'? tests/cases/compiler/commonMissingSemicolons.ts(16,1): error TS2304: Cannot find name 'constd'. tests/cases/compiler/commonMissingSemicolons.ts(16,8): error TS2304: Cannot find name 'myConst3'. -tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS1435: Unknown keyword or identifier. Did you mean 'declare'? tests/cases/compiler/commonMissingSemicolons.ts(19,1): error TS2304: Cannot find name 'declared'. tests/cases/compiler/commonMissingSemicolons.ts(20,1): error TS2304: Cannot find name 'declare'. -tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS1435: Unknown keyword or identifier. Did you mean 'const'? tests/cases/compiler/commonMissingSemicolons.ts(20,9): error TS2304: Cannot find name 'constd'. -tests/cases/compiler/commonMissingSemicolons.ts(21,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +tests/cases/compiler/commonMissingSemicolons.ts(21,1): error TS1435: Unknown keyword or identifier. Did you mean 'declare'? tests/cases/compiler/commonMissingSemicolons.ts(21,1): error TS2304: Cannot find name 'declared'. -tests/cases/compiler/commonMissingSemicolons.ts(21,10): error TS1434: Unknown keyword or identifier. Did you mean 'const'? +tests/cases/compiler/commonMissingSemicolons.ts(21,10): error TS1435: Unknown keyword or identifier. Did you mean 'const'? tests/cases/compiler/commonMissingSemicolons.ts(21,10): error TS2304: Cannot find name 'constd'. -tests/cases/compiler/commonMissingSemicolons.ts(22,1): error TS1434: Unknown keyword or identifier. Did you mean 'declare const'? +tests/cases/compiler/commonMissingSemicolons.ts(22,1): error TS1435: Unknown keyword or identifier. Did you mean 'declare const'? tests/cases/compiler/commonMissingSemicolons.ts(22,1): error TS2304: Cannot find name 'declareconst'. tests/cases/compiler/commonMissingSemicolons.ts(22,14): error TS2304: Cannot find name 'myDeclareConst5'. -tests/cases/compiler/commonMissingSemicolons.ts(25,1): error TS1434: Unknown keyword or identifier. Did you mean 'function'? +tests/cases/compiler/commonMissingSemicolons.ts(25,1): error TS1435: Unknown keyword or identifier. Did you mean 'function'? tests/cases/compiler/commonMissingSemicolons.ts(25,1): error TS2304: Cannot find name 'functiond'. tests/cases/compiler/commonMissingSemicolons.ts(25,11): error TS2304: Cannot find name 'myFunction2'. tests/cases/compiler/commonMissingSemicolons.ts(25,25): error TS1005: ';' expected. tests/cases/compiler/commonMissingSemicolons.ts(26,10): error TS1359: Identifier expected. 'function' is a reserved word that cannot be used here. tests/cases/compiler/commonMissingSemicolons.ts(26,18): error TS1003: Identifier expected. tests/cases/compiler/commonMissingSemicolons.ts(27,1): error TS2304: Cannot find name 'functionMyFunction'. -tests/cases/compiler/commonMissingSemicolons.ts(30,1): error TS1434: Unknown keyword or identifier. Did you mean 'interface'? +tests/cases/compiler/commonMissingSemicolons.ts(30,1): error TS1435: Unknown keyword or identifier. Did you mean 'interface'? tests/cases/compiler/commonMissingSemicolons.ts(30,1): error TS2304: Cannot find name 'interfaced'. -tests/cases/compiler/commonMissingSemicolons.ts(30,12): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/commonMissingSemicolons.ts(30,12): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/commonMissingSemicolons.ts(30,12): error TS2304: Cannot find name 'myInterface2'. tests/cases/compiler/commonMissingSemicolons.ts(32,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. -tests/cases/compiler/commonMissingSemicolons.ts(32,11): error TS1437: Interface must be given a name. +tests/cases/compiler/commonMissingSemicolons.ts(32,11): error TS1438: Interface must be given a name. tests/cases/compiler/commonMissingSemicolons.ts(33,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. tests/cases/compiler/commonMissingSemicolons.ts(33,11): error TS2427: Interface name cannot be 'void'. -tests/cases/compiler/commonMissingSemicolons.ts(34,1): error TS1434: Unknown keyword or identifier. Did you mean 'interface MyInterface'? +tests/cases/compiler/commonMissingSemicolons.ts(34,1): error TS1435: Unknown keyword or identifier. Did you mean 'interface MyInterface'? tests/cases/compiler/commonMissingSemicolons.ts(34,1): error TS2304: Cannot find name 'interfaceMyInterface'. -tests/cases/compiler/commonMissingSemicolons.ts(38,1): error TS1434: Unknown keyword or identifier. Did you mean 'let'? +tests/cases/compiler/commonMissingSemicolons.ts(38,1): error TS1435: Unknown keyword or identifier. Did you mean 'let'? tests/cases/compiler/commonMissingSemicolons.ts(38,1): error TS2304: Cannot find name 'letd'. tests/cases/compiler/commonMissingSemicolons.ts(38,6): error TS2304: Cannot find name 'let2'. tests/cases/compiler/commonMissingSemicolons.ts(39,1): error TS2304: Cannot find name 'letMyLet'. tests/cases/compiler/commonMissingSemicolons.ts(41,10): error TS1005: '=' expected. -tests/cases/compiler/commonMissingSemicolons.ts(45,1): error TS1434: Unknown keyword or identifier. Did you mean 'type'? +tests/cases/compiler/commonMissingSemicolons.ts(45,1): error TS1435: Unknown keyword or identifier. Did you mean 'type'? tests/cases/compiler/commonMissingSemicolons.ts(45,1): error TS2304: Cannot find name 'typed'. tests/cases/compiler/commonMissingSemicolons.ts(45,7): error TS2304: Cannot find name 'type4'. -tests/cases/compiler/commonMissingSemicolons.ts(46,1): error TS1434: Unknown keyword or identifier. Did you mean 'type'? +tests/cases/compiler/commonMissingSemicolons.ts(46,1): error TS1435: Unknown keyword or identifier. Did you mean 'type'? tests/cases/compiler/commonMissingSemicolons.ts(46,1): error TS2304: Cannot find name 'typed'. tests/cases/compiler/commonMissingSemicolons.ts(46,7): error TS2304: Cannot find name 'type5'. tests/cases/compiler/commonMissingSemicolons.ts(46,15): error TS2693: 'type' only refers to a type, but is being used as a value here. tests/cases/compiler/commonMissingSemicolons.ts(47,1): error TS2304: Cannot find name 'typeMyType'. -tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS1434: Unknown keyword or identifier. Did you mean 'var'? +tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS1435: Unknown keyword or identifier. Did you mean 'var'? tests/cases/compiler/commonMissingSemicolons.ts(50,1): error TS2304: Cannot find name 'vard'. tests/cases/compiler/commonMissingSemicolons.ts(50,6): error TS2304: Cannot find name 'myVar2'. tests/cases/compiler/commonMissingSemicolons.ts(51,1): error TS2304: Cannot find name 'varMyVar'. @@ -80,12 +80,12 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration async function myAsyncFunction1() {} asynd function myAsyncFunction2() {} ~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'async'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'async'? ~~~~~ !!! error TS2304: Cannot find name 'asynd'. sasync function myAsyncFunction3() {} ~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'async'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'async'? ~~~~~~ !!! error TS2304: Cannot find name 'sasync'. @@ -101,21 +101,21 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration class MyClass1 {} clasd MyClass2 {} ~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'class'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'class'? ~~~~~ !!! error TS2304: Cannot find name 'clasd'. ~~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~~~~~ !!! error TS2552: Cannot find name 'MyClass2'. Did you mean 'MyClass1'? !!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:10:7: 'MyClass1' is declared here. classs MyClass3 {} ~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'class'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'class'? ~~~~~~ !!! error TS2304: Cannot find name 'classs'. ~~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~~~~~ !!! error TS2552: Cannot find name 'MyClass3'. Did you mean 'MyClass1'? !!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:10:7: 'MyClass1' is declared here. @@ -123,7 +123,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration const myConst1 = 1; consd myConst2 = 1; ~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'const'? ~~~~~ !!! error TS2304: Cannot find name 'consd'. ~~~~~~~~ @@ -131,7 +131,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration !!! related TS2728 tests/cases/compiler/commonMissingSemicolons.ts:14:7: 'myConst1' is declared here. constd myConst3 = 1; ~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'const'? ~~~~~~ !!! error TS2304: Cannot find name 'constd'. ~~~~~~~~ @@ -140,28 +140,28 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration declare const myDeclareConst1: 1; declared const myDeclareConst2: 1; ~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'declare'? ~~~~~~~~ !!! error TS2304: Cannot find name 'declared'. declare constd myDeclareConst3: 1; ~~~~~~~ !!! error TS2304: Cannot find name 'declare'. ~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'const'? ~~~~~~ !!! error TS2304: Cannot find name 'constd'. declared constd myDeclareConst4: 1; ~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'declare'? ~~~~~~~~ !!! error TS2304: Cannot find name 'declared'. ~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'const'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'const'? ~~~~~~ !!! error TS2304: Cannot find name 'constd'. declareconst myDeclareConst5; ~~~~~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'declare const'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'declare const'? ~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'declareconst'. ~~~~~~~~~~~~~~~ @@ -170,7 +170,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration function myFunction1() { } functiond myFunction2() { } ~~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'function'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'function'? ~~~~~~~~~ !!! error TS2304: Cannot find name 'functiond'. ~~~~~~~~~~~ @@ -189,11 +189,11 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration interface myInterface1 { } interfaced myInterface2 { } ~~~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'interface'? ~~~~~~~~~~ !!! error TS2304: Cannot find name 'interfaced'. ~~~~~~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'myInterface2'. interface interface { } @@ -201,7 +201,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration ~~~~~~~~~ !!! error TS2693: 'interface' only refers to a type, but is being used as a value here. ~ -!!! error TS1437: Interface must be given a name. +!!! error TS1438: Interface must be given a name. interface void { } ~~~~~~~~~ !!! error TS2693: 'interface' only refers to a type, but is being used as a value here. @@ -209,7 +209,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration !!! error TS2427: Interface name cannot be 'void'. interfaceMyInterface { } ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface MyInterface'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'interface MyInterface'? ~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'interfaceMyInterface'. @@ -217,7 +217,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration let let1 = 1; letd let2 = 1; ~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'let'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'let'? ~~~~ !!! error TS2304: Cannot find name 'letd'. ~~~~ @@ -234,14 +234,14 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration type type3 = {}; typed type4 = {} ~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'type'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'type'? ~~~~~ !!! error TS2304: Cannot find name 'typed'. ~~~~~ !!! error TS2304: Cannot find name 'type4'. typed type5 = type; ~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'type'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'type'? ~~~~~ !!! error TS2304: Cannot find name 'typed'. ~~~~~ @@ -255,7 +255,7 @@ tests/cases/compiler/commonMissingSemicolons.ts(78,1): error TS1128: Declaration var myVar1 = 1; vard myVar2 = 1; ~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'var'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'var'? ~~~~ !!! error TS2304: Cannot find name 'vard'. ~~~~~~ diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt index aca7ad46e127b..39de6565e2531 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4 class C { public @dec get accessor() { return 1; } ~ -!!! error TS1435: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt index 3d66c6796b3e8..f8b9a9f4b47a9 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4 class C { public @dec set accessor(value: number) { } ~ -!!! error TS1435: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt index 0666e5c333be7..5d098d7f3cda0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12) class C { public @dec method() {} ~ -!!! error TS1435: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt index 2333d9eee9843..7569c691d56e3 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1435: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. ==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4 class C { public @dec prop; ~ -!!! error TS1435: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede all other keywords for property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index 18d78664e99c7..d8abbb9b38149 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1440: Function call is not a type annotation. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1441: Function call is not a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1440: Function call is not a type annotation. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1441: Function call is not a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. @@ -24,7 +24,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1440: Function call is not a type annotation. +!!! error TS1441: Function call is not a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. b() { @@ -48,7 +48,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1440: Function call is not a type annotation. +!!! error TS1441: Function call is not a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. static b() { diff --git a/tests/baselines/reference/emitBOM.js b/tests/baselines/reference/emitBOM.js index 2e905d95a0a87..4717bf52a0b3b 100644 --- a/tests/baselines/reference/emitBOM.js +++ b/tests/baselines/reference/emitBOM.js @@ -2,7 +2,7 @@ // JS and d.ts output should have a BOM but not the sourcemap var x; -tests/cases/compiler/emitBOM.js(1,1): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/emitBOM.js(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/emitBOM.js(1,2): error TS1127: Invalid character. tests/cases/compiler/emitBOM.js(1,2): error TS1128: Declaration or statement expected. tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character. @@ -11,7 +11,7 @@ tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character. ==== tests/cases/compiler/emitBOM.js (4 errors) ==== // JS and d.ts output should have a BOM but not the sourcemap ~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. !!! error TS1127: Invalid character. ~ diff --git a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt index aa65a47f774c1..ff928a4b62cf2 100644 --- a/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportParsingError.errors.txt @@ -1,13 +1,13 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,10): error TS1003: Identifier expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,10): error TS1141: String literal expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,12): error TS1109: Expression expected. -tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(1,14): error TS2304: Cannot find name 'from'. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: Module '"tests/cases/compiler/es6ImportNamedImportParsingError_0"' has no default export. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(2,24): error TS1005: '{' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,1): error TS1128: Declaration or statement expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,8): error TS1128: Declaration or statement expected. -tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,16): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,16): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(3,16): error TS2304: Cannot find name 'from'. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,13): error TS1005: 'from' expected. tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,13): error TS1141: String literal expected. @@ -28,7 +28,7 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ~ !!! error TS1109: Expression expected. ~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~ !!! error TS2304: Cannot find name 'from'. import defaultBinding, from "es6ImportNamedImportParsingError_0"; @@ -42,7 +42,7 @@ tests/cases/compiler/es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ~ !!! error TS1128: Declaration or statement expected. ~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~ !!! error TS2304: Cannot find name 'from'. import { a }, from "es6ImportNamedImportParsingError_0"; diff --git a/tests/baselines/reference/extension.errors.txt b/tests/baselines/reference/extension.errors.txt index 88bcc1eb4dbe3..b7828e1d05143 100644 --- a/tests/baselines/reference/extension.errors.txt +++ b/tests/baselines/reference/extension.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/extension.ts(10,18): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/extension.ts(16,5): error TS1128: Declaration or statement expected. -tests/cases/compiler/extension.ts(16,12): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/extension.ts(16,12): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/extension.ts(16,12): error TS2304: Cannot find name 'extension'. tests/cases/compiler/extension.ts(16,28): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not exist on type 'C'. @@ -28,7 +28,7 @@ tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not ex ~~~~~~ !!! error TS1128: Declaration or statement expected. ~~~~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~~~~~~ !!! error TS2304: Cannot find name 'extension'. ~ diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index 6b8eedd16e9e1..438db5d0e77bb 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/externModule.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/compiler/externModule.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/externModule.ts(1,16): error TS1436: Namespace must be given a name. +tests/cases/compiler/externModule.ts(1,16): error TS1437: Namespace must be given a name. tests/cases/compiler/externModule.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/compiler/externModule.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/compiler/externModule.ts(18,6): error TS2390: Constructor implementation is missing. @@ -20,7 +20,7 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. export class XDate { public getDay():number; ~~~~~~ diff --git a/tests/baselines/reference/innerModExport1.errors.txt b/tests/baselines/reference/innerModExport1.errors.txt index 4d37d6c033d62..26e4b8d09006c 100644 --- a/tests/baselines/reference/innerModExport1.errors.txt +++ b/tests/baselines/reference/innerModExport1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/innerModExport1.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/innerModExport1.ts(5,12): error TS1436: Namespace must be given a name. +tests/cases/compiler/innerModExport1.ts(5,12): error TS1437: Namespace must be given a name. ==== tests/cases/compiler/innerModExport1.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/innerModExport1.ts(5,12): error TS1436: Namespace must be g ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. var non_export_var = 0; export var export_var = 1; diff --git a/tests/baselines/reference/innerModExport2.errors.txt b/tests/baselines/reference/innerModExport2.errors.txt index b487d510f0543..7057b7e6d7aa1 100644 --- a/tests/baselines/reference/innerModExport2.errors.txt +++ b/tests/baselines/reference/innerModExport2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/innerModExport2.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/innerModExport2.ts(5,12): error TS1436: Namespace must be given a name. +tests/cases/compiler/innerModExport2.ts(5,12): error TS1437: Namespace must be given a name. tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local. tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExportFunc' does not exist on type 'typeof Outer'. @@ -14,7 +14,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~ -!!! error TS1436: Namespace must be given a name. +!!! error TS1437: Namespace must be given a name. var non_export_var = 0; export var export_var = 1; ~~~~~~~~~~ diff --git a/tests/baselines/reference/interfaceDeclaration4.errors.txt b/tests/baselines/reference/interfaceDeclaration4.errors.txt index 35d4fc6bac6c4..58f487dd02997 100644 --- a/tests/baselines/reference/interfaceDeclaration4.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration4.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/interfaceDeclaration4.ts(27,7): error TS2420: Class 'C2' in tests/cases/compiler/interfaceDeclaration4.ts(36,7): error TS2420: Class 'C3' incorrectly implements interface 'I1'. Property 'item' is missing in type 'C3' but required in type 'I1'. tests/cases/compiler/interfaceDeclaration4.ts(39,14): error TS1005: '{' expected. -tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS2304: Cannot find name 'I1'. @@ -65,7 +65,7 @@ tests/cases/compiler/interfaceDeclaration4.ts(39,15): error TS2304: Cannot find ~ !!! error TS1005: '{' expected. ~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~ !!! error TS2304: Cannot find name 'I1'. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceNaming1.errors.txt b/tests/baselines/reference/interfaceNaming1.errors.txt index 55e5a1b13218c..30026d6335280 100644 --- a/tests/baselines/reference/interfaceNaming1.errors.txt +++ b/tests/baselines/reference/interfaceNaming1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. -tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1437: Interface must be given a name. +tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1438: Interface must be given a name. tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. @@ -9,7 +9,7 @@ tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand sid ~~~~~~~~~ !!! error TS2693: 'interface' only refers to a type, but is being used as a value here. ~ -!!! error TS1437: Interface must be given a name. +!!! error TS1438: Interface must be given a name. interface interface{ } interface & { } ~~~~~~~~~ diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt index 9511968028ab5..da294ddd7b3b7 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS2304: Cannot find name 'a'. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1127: Invalid character. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1128: Declaration or statement expected. @@ -8,7 +8,7 @@ tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,3): error TS2304: Cannot ==== tests/cases/compiler/invalidUnicodeEscapeSequance3.ts (5 errors) ==== a\u ~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~ !!! error TS2304: Cannot find name 'a'. diff --git a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt index aba087fec310e..c98dfa1cf7f22 100644 --- a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt +++ b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(2,17): error TS1005: ':' tests/cases/compiler/parseErrorIncorrectReturnToken.ts(4,22): error TS1005: '=>' expected. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(4,24): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,18): error TS1005: '{' expected. -tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,21): error TS1433: Unexpected keyword or identifier. +tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,21): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(9,21): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Declaration or statement expected. @@ -26,7 +26,7 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Decl ~~ !!! error TS1005: '{' expected. ~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. return n.toString(); diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt index e985bf46061e1..c9f5d90f09324 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/12.ts(1,2): erro tests/cases/conformance/parser/ecmascript2021/numericSeparators/13.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/14.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/15.ts(1,5): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascript2021/numericSeparators/16.ts(1,1): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript2021/numericSeparators/16.ts(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript2021/numericSeparators/16.ts(1,1): error TS2304: Cannot find name '_0'. tests/cases/conformance/parser/ecmascript2021/numericSeparators/17.ts(1,6): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/18.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -20,7 +20,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/25.ts(1,2): erro tests/cases/conformance/parser/ecmascript2021/numericSeparators/26.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/27.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/28.ts(1,6): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascript2021/numericSeparators/29.ts(1,1): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript2021/numericSeparators/29.ts(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript2021/numericSeparators/29.ts(1,1): error TS2304: Cannot find name '_0'. tests/cases/conformance/parser/ecmascript2021/numericSeparators/3.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascript2021/numericSeparators/30.ts(1,7): error TS6188: Numeric separators are not allowed here. @@ -36,7 +36,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/39.ts(1,3): erro tests/cases/conformance/parser/ecmascript2021/numericSeparators/4.ts(1,2): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/40.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/41.ts(1,6): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascript2021/numericSeparators/42.ts(1,1): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript2021/numericSeparators/42.ts(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript2021/numericSeparators/42.ts(1,1): error TS2304: Cannot find name '_0'. tests/cases/conformance/parser/ecmascript2021/numericSeparators/43.ts(1,7): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascript2021/numericSeparators/44.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -136,7 +136,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascript2021/numericSeparators/16.ts (2 errors) ==== _0.0e0 ~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~ !!! error TS2304: Cannot find name '_0'. @@ -203,7 +203,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascript2021/numericSeparators/29.ts (2 errors) ==== _0.0e+0 ~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~ !!! error TS2304: Cannot find name '_0'. @@ -270,7 +270,7 @@ tests/cases/conformance/parser/ecmascript2021/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascript2021/numericSeparators/42.ts (2 errors) ==== _0.0e-0 ~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~ !!! error TS2304: Cannot find name '_0'. diff --git a/tests/baselines/reference/parser0_004152.errors.txt b/tests/baselines/reference/parser0_004152.errors.txt index 935e51b77dfb1..a1790a5f7305c 100644 --- a/tests/baselines/reference/parser0_004152.errors.txt +++ b/tests/baselines/reference/parser0_004152.errors.txt @@ -26,7 +26,7 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,82): error T tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,84): error TS2300: Duplicate identifier '0'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,85): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,86): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,88): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,88): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,94): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,96): error TS2300: Duplicate identifier '0'. tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,97): error TS1005: ';' expected. @@ -93,7 +93,7 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~~~~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~ diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt index 0e1438ddc8b29..f5602fea178b1 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,20): error TS2304: Cannot find name 'C'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1441: Missing '=' before default property value. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1442: Missing '=' before default property value. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariabl ~ !!! error TS2304: Cannot find name 'C'. ~~~~~~~ -!!! error TS1441: Missing '=' before default property value. +!!! error TS1442: Missing '=' before default property value. // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserFuzz1.errors.txt b/tests/baselines/reference/parserFuzz1.errors.txt index 8416da64eef83..6ab8b1489e2e7 100644 --- a/tests/baselines/reference/parserFuzz1.errors.txt +++ b/tests/baselines/reference/parserFuzz1.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,1): error TS2304: Cannot find name 'cla'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,6): error TS2304: Cannot find name 'ss'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(1,9): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,3): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,3): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,3): error TS2304: Cannot find name '_'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,5): error TS1128: Declaration or statement expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): error TS1005: '{' expected. @@ -17,7 +17,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): e !!! error TS1005: ';' expected. _ static try ~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~ !!! error TS2304: Cannot find name '_'. ~~~~~~ diff --git a/tests/baselines/reference/parserSkippedTokens16.errors.txt b/tests/baselines/reference/parserSkippedTokens16.errors.txt index 1f70fce5f444c..ab3f1afa12273 100644 --- a/tests/baselines/reference/parserSkippedTokens16.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens16.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,1): error TS2552: Cannot find name 'foo'. Did you mean 'Foo'? tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,6): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,8): error TS1433: Unexpected keyword or identifier. +tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,8): error TS1434: Unexpected keyword or identifier. tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,8): error TS2304: Cannot find name 'Bar'. tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(2,22): error TS1127: Invalid character. tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(3,3): error TS1109: Expression expected. @@ -16,7 +16,7 @@ tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.t ~ !!! error TS1005: ';' expected. ~~~ -!!! error TS1433: Unexpected keyword or identifier. +!!! error TS1434: Unexpected keyword or identifier. ~~~ !!! error TS2304: Cannot find name 'Bar'. function Foo () ¬ { } diff --git a/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt b/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt index d5cdba3096b41..a470237cef2e3 100644 --- a/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt +++ b/tests/baselines/reference/parserUnterminatedGeneric2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(2,5): error TS1434: Unknown keyword or identifier. Did you mean 'interface ICompiledExpression'? +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(2,5): error TS1435: Unknown keyword or identifier. Did you mean 'interface ICompiledExpression'? tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(2,5): error TS2304: Cannot find name 'interfaceICompiledExpression'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(3,42): error TS1005: '=>' expected. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGeneric2.ts(4,9): error TS2304: Cannot find name 'assign'. @@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnterminatedGener declare module ng { interfaceICompiledExpression { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1434: Unknown keyword or identifier. Did you mean 'interface ICompiledExpression'? +!!! error TS1435: Unknown keyword or identifier. Did you mean 'interface ICompiledExpression'? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'interfaceICompiledExpression'. (context: any, locals?: any): any; diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index 2a86a63f53021..d91aa077fd6b1 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,12): error TS1441: Missing '=' before default property value. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,12): error TS1442: Missing '=' before default property value. ==== tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts (5 errors) ==== @@ -29,5 +29,5 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces a: this.foo; // error ~ -!!! error TS1441: Missing '=' before default property value. +!!! error TS1442: Missing '=' before default property value. } \ No newline at end of file diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 4dabd4704af92..91fa82b7ef1c0 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/reservedWords2.ts(5,9): error TS2567: Enum declarations can tests/cases/compiler/reservedWords2.ts(5,10): error TS1359: Identifier expected. 'throw' is a reserved word that cannot be used here. tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected. tests/cases/compiler/reservedWords2.ts(6,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -tests/cases/compiler/reservedWords2.ts(6,8): error TS2810: Namespace name cannot be 'void'. +tests/cases/compiler/reservedWords2.ts(6,8): error TS2813: Namespace name cannot be 'void'. tests/cases/compiler/reservedWords2.ts(7,11): error TS2300: Duplicate identifier '(Missing)'. tests/cases/compiler/reservedWords2.ts(7,11): error TS1005: ':' expected. tests/cases/compiler/reservedWords2.ts(7,19): error TS2300: Duplicate identifier '(Missing)'. @@ -79,7 +79,7 @@ tests/cases/compiler/reservedWords2.ts(12,17): error TS1138: Parameter declarati ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ~~~~ -!!! error TS2810: Namespace name cannot be 'void'. +!!! error TS2813: Namespace name cannot be 'void'. var {while, return} = { while: 1, return: 2 }; !!! error TS2300: Duplicate identifier '(Missing)'. diff --git a/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt b/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt index 28e5a76f2169a531c257f39ce6f86998ecc7510a..739e922ac83e9191bebc004bfe4823f473679bbb 100644 GIT binary patch delta 22 ecmdnSxs7u|0;9>sL}g}1lZlC{n^!UOFaiKmiUySc delta 22 ecmdnSxs7u|0;BQ9L}g}1 Date: Mon, 12 Apr 2021 22:33:01 -0400 Subject: [PATCH 10/17] Update src/compiler/parser.ts Co-authored-by: Daniel Rosenwasser --- src/compiler/parser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e26012611a25d..4bbabd11a0baa 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2569,8 +2569,8 @@ namespace ts { case ParsingContext.SwitchClauseStatements: return parseErrorAtCurrentToken(Diagnostics.Statement_expected); case ParsingContext.RestProperties: // fallthrough case ParsingContext.TypeMembers: return parseErrorAtCurrentToken(Diagnostics.Property_or_signature_expected); - case ParsingContext.ClassMembers: - return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case ParsingContext.ClassMembers: return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case ParsingContext.EnumMembers: return parseErrorAtCurrentToken(Diagnostics.Enum_member_expected); case ParsingContext.HeritageClauseElement: return parseErrorAtCurrentToken(Diagnostics.Expression_expected); case ParsingContext.VariableDeclarations: From dabe89a6b568c361e4847df79fd041898cafdb16 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 13 Apr 2021 00:09:05 -0400 Subject: [PATCH 11/17] Mostly addressed feedback --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 70 ++++++++++++------- .../decoratorOnClassAccessor3.errors.txt | 4 +- .../decoratorOnClassAccessor6.errors.txt | 4 +- .../decoratorOnClassMethod3.errors.txt | 4 +- .../decoratorOnClassProperty3.errors.txt | 4 +- 6 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9e0a76aa05edc..e548d620ad0d9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1372,7 +1372,7 @@ "category": "Error", "code": 1435 }, - "Decorators must precede all other keywords for property declarations.": { + "Decorators must precede the name and all keywords of property declarations.": { "category": "Error", "code": 1436 }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4bbabd11a0baa..0d5d81602b813 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1539,7 +1539,17 @@ namespace ts { const viableKeywordSuggestions = Object.keys(textToKeywordObj).filter(keyword => keyword.length > 2); - function parseSemicolonAfter(parentKind: SyntaxKind, expression: Expression | PropertyName, initializer?: Node) { + /** + * Attempts to consume the expected semicolon after an expression or property name. + * + * @param parentKind Kind of block the node and its expected semicolon are within. + * @param node Node preceding the expected semicolon location. + * @param initializer The preceding node's initializer, if it may exist and was able to parse. + * @remarks + * Use this to get a better error message than the generic "';' expected" if possible for + * known common variants of invalid syntax, such as mispelled names. + */ + function parseSemicolonAfter(parentKind: SyntaxKind, node: Expression | PropertyName, initializer?: Node) { // Consume the semicolon if it was explicitly provided. if (canParseSemicolon()) { if (token() === SyntaxKind.SemicolonToken) { @@ -1549,11 +1559,15 @@ namespace ts { return; } - // The only way not having a semicolon after an expression when expected shouldn't create an error - // would be if there's an initializer, which would indicate the initializer already has an error... + // If an initializer was parsed but there is still an error in finding the next semicolon, + // we generally know there was an error already reported in the initializer... + // class Example { a = new Map([), ) } + // ~ if (initializer) { - // ...unless we're parsing property declarations, in which case we can know that the initializer - // was fine but we included something invalid immediately after it + // ...unless we've found the start of a block after a property declaration, in which + // case we can know that regardless of the initializer we should complain on the block. + // class Example { a = 0 {} } + // ~ if (token() === SyntaxKind.OpenBraceToken && parentKind === SyntaxKind.PropertyDeclaration) { parseErrorAtCurrentToken(Diagnostics._0_expected, ";"); } @@ -1564,26 +1578,26 @@ namespace ts { // Tagged template literals are sometimes used in places where only simple strings are allowed, i.e.: // module `M1` { // ^^^^^^^^^^^ This block is parsed as a template literal like module`M1`. - if (isTaggedTemplateExpression(expression)) { - parseErrorAt(skipTrivia(sourceText, expression.template.pos), expression.template.end, Diagnostics.Module_declaration_names_may_only_use_or_quoted_strings); + if (isTaggedTemplateExpression(node)) { + parseErrorAt(skipTrivia(sourceText, node.template.pos), node.template.end, Diagnostics.Module_declaration_names_may_only_use_or_quoted_strings); return; } // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. - const expressionText = getExpressionText(expression); + const expressionText = getExpressionText(node); if (!expressionText || !isIdentifierText(expressionText, languageVersion)) { parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); return; } - const pos = skipTrivia(sourceText, expression.pos); + const pos = skipTrivia(sourceText, node.pos); // Some known keywords are likely signs of syntax being used improperly. switch (expressionText) { case "const": case "let": case "var": - parseErrorAt(pos, expression.end, Diagnostics.Variable_declaration_not_allowed_at_this_location); + parseErrorAt(pos, node.end, Diagnostics.Variable_declaration_not_allowed_at_this_location); return; case "declare": @@ -1591,7 +1605,7 @@ namespace ts { return; case "interface": - parseErrorForExpectedName(scanner.getTokenText(), "{", Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0); + parseErrorForInvalidName(SyntaxKind.OpenBraceToken, Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0); return; case "is": @@ -1600,31 +1614,38 @@ namespace ts { case "module": case "namespace": - parseErrorForExpectedName(scanner.getTokenText(), "{", Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0); + parseErrorForInvalidName(SyntaxKind.OpenBraceToken, Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0); return; case "type": - parseErrorForExpectedName(scanner.getTokenText(), "=", Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0); + parseErrorForInvalidName(SyntaxKind.EqualsToken, Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0); return; } - // The user alternately might have misspelled or forgotten to add a space after a common keyword. - const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, n => n) || getSpaceSuggestion(expressionText); + // The user alternatively might have misspelled or forgotten to add a space after a common keyword. + const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, n => n) ?? getSpaceSuggestion(expressionText); if (suggestion) { - parseErrorAt(pos, expression.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); + parseErrorAt(pos, node.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); return; } // We know this is a slightly more precise case than a missing expected semicolon. - parseErrorAt(pos, expression.end, Diagnostics.Unexpected_keyword_or_identifier); + parseErrorAt(pos, node.end, Diagnostics.Unexpected_keyword_or_identifier); } - function parseErrorForExpectedName(name: string, normalToken: string, blankDiagnostic: DiagnosticMessage, nameDiagnostic: DiagnosticMessage) { - if (name === normalToken) { + /** + * Reports a diagnostic error for the current token being an invalid name. + * + * @param tokenIfBlankName Current token if the name was invalid for being blank (not provided / skipped). + * @param blankDiagnostic Diagnostic to report for the case of the name being blank (matched tokenIfBlankName). + * @param nameDiagnostic Diagnostic to report for all other cases. + */ + function parseErrorForInvalidName(tokenIfBlankName: SyntaxKind, blankDiagnostic: DiagnosticMessage, nameDiagnostic: DiagnosticMessage) { + if (token() === tokenIfBlankName) { parseErrorAtCurrentToken(blankDiagnostic); } else { - parseErrorAtCurrentToken(nameDiagnostic, name); + parseErrorAtCurrentToken(nameDiagnostic, tokenToString(token())); } } @@ -1639,12 +1660,12 @@ namespace ts { } function parseSemicolonAfterPropertyName(name: PropertyName, type: TypeNode | undefined, initializer: Expression | undefined) { - switch (scanner.getTokenText()) { - case "@": - parseErrorAtCurrentToken(Diagnostics.Decorators_must_precede_all_other_keywords_for_property_declarations); + switch (token()) { + case SyntaxKind.AtToken: + parseErrorAtCurrentToken(Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; - case "(": + case SyntaxKind.OpenParenToken: parseErrorAtCurrentToken(Diagnostics.Function_call_is_not_a_type_annotation); nextToken(); return; @@ -2570,7 +2591,6 @@ namespace ts { case ParsingContext.RestProperties: // fallthrough case ParsingContext.TypeMembers: return parseErrorAtCurrentToken(Diagnostics.Property_or_signature_expected); case ParsingContext.ClassMembers: return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case ParsingContext.EnumMembers: return parseErrorAtCurrentToken(Diagnostics.Enum_member_expected); case ParsingContext.HeritageClauseElement: return parseErrorAtCurrentToken(Diagnostics.Expression_expected); case ParsingContext.VariableDeclarations: diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt index 39de6565e2531..f57ce1f2927ca 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1436: Decorators must precede the name and all keywords of property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4 class C { public @dec get accessor() { return 1; } ~ -!!! error TS1436: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede the name and all keywords of property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt index f8b9a9f4b47a9..1f18744c7c5ef 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt +++ b/tests/baselines/reference/decoratorOnClassAccessor6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1436: Decorators must precede the name and all keywords of property declarations. ==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4 class C { public @dec set accessor(value: number) { } ~ -!!! error TS1436: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede the name and all keywords of property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt index 5d098d7f3cda0..5d5be3f17125e 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1436: Decorators must precede the name and all keywords of property declarations. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12) class C { public @dec method() {} ~ -!!! error TS1436: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede the name and all keywords of property declarations. } \ No newline at end of file diff --git a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt index 7569c691d56e3..d21e42db43736 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.errors.txt +++ b/tests/baselines/reference/decoratorOnClassProperty3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1436: Decorators must precede all other keywords for property declarations. +tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1436: Decorators must precede the name and all keywords of property declarations. ==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4 class C { public @dec prop; ~ -!!! error TS1436: Decorators must precede all other keywords for property declarations. +!!! error TS1436: Decorators must precede the name and all keywords of property declarations. } \ No newline at end of file From 6d40a4c7faeaa7bb2096c3f5712e77f815825345 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 16 Apr 2021 20:34:49 -0400 Subject: [PATCH 12/17] Clarified function call type message --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 6 +++--- ...rivedClassSuperCallsInNonConstructorMembers.errors.txt | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e548d620ad0d9..1f5a493166e40 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1392,7 +1392,7 @@ "category": "Error", "code": 1440 }, - "Function call is not a type annotation.": { + "Cannot start a function call in a type annotation.": { "category": "Error", "code": 1441 }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0d5d81602b813..67a67759258ab 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1666,7 +1666,7 @@ namespace ts { return; case SyntaxKind.OpenParenToken: - parseErrorAtCurrentToken(Diagnostics.Function_call_is_not_a_type_annotation); + parseErrorAtCurrentToken(Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } @@ -1685,8 +1685,8 @@ namespace ts { } function getExpressionText(expression: Expression | PropertyName) { - return expression && ts.isIdentifier(expression) - ? expression.escapedText.toString() + return ts.isIdentifier(expression) + ? idText(expression) : undefined; } diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index d8abbb9b38149..eb44057eadf0c 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1441: Function call is not a type annotation. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1441: Cannot start a function call in a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1441: Function call is not a type annotation. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1441: Cannot start a function call in a type annotation. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. @@ -24,7 +24,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1441: Function call is not a type annotation. +!!! error TS1441: Cannot start a function call in a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. b() { @@ -48,7 +48,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1441: Function call is not a type annotation. +!!! error TS1441: Cannot start a function call in a type annotation. ~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. static b() { From 7e49aa6ce040a910d567315b28f1385baf117fec Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 16 Apr 2021 21:11:30 -0400 Subject: [PATCH 13/17] Split up and clarified parsing vs error functions --- src/compiler/parser.ts | 99 ++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 67a67759258ab..de316fe32e70f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1540,41 +1540,13 @@ namespace ts { const viableKeywordSuggestions = Object.keys(textToKeywordObj).filter(keyword => keyword.length > 2); /** - * Attempts to consume the expected semicolon after an expression or property name. + * Provides a better error message than the generic "';' expected" if possible for + * known common variants of a missing semicolon, such as from a mispelled names. * - * @param parentKind Kind of block the node and its expected semicolon are within. * @param node Node preceding the expected semicolon location. - * @param initializer The preceding node's initializer, if it may exist and was able to parse. * @remarks - * Use this to get a better error message than the generic "';' expected" if possible for - * known common variants of invalid syntax, such as mispelled names. */ - function parseSemicolonAfter(parentKind: SyntaxKind, node: Expression | PropertyName, initializer?: Node) { - // Consume the semicolon if it was explicitly provided. - if (canParseSemicolon()) { - if (token() === SyntaxKind.SemicolonToken) { - nextToken(); - } - - return; - } - - // If an initializer was parsed but there is still an error in finding the next semicolon, - // we generally know there was an error already reported in the initializer... - // class Example { a = new Map([), ) } - // ~ - if (initializer) { - // ...unless we've found the start of a block after a property declaration, in which - // case we can know that regardless of the initializer we should complain on the block. - // class Example { a = 0 {} } - // ~ - if (token() === SyntaxKind.OpenBraceToken && parentKind === SyntaxKind.PropertyDeclaration) { - parseErrorAtCurrentToken(Diagnostics._0_expected, ";"); - } - - return; - } - + function parseErrorForMissingSemicolonAfter(node: Expression | PropertyName): void { // Tagged template literals are sometimes used in places where only simple strings are allowed, i.e.: // module `M1` { // ^^^^^^^^^^^ This block is parsed as a template literal like module`M1`. @@ -1605,7 +1577,7 @@ namespace ts { return; case "interface": - parseErrorForInvalidName(SyntaxKind.OpenBraceToken, Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0); + parseErrorForInvalidName(Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0, SyntaxKind.OpenBraceToken); return; case "is": @@ -1614,11 +1586,11 @@ namespace ts { case "module": case "namespace": - parseErrorForInvalidName(SyntaxKind.OpenBraceToken, Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0); + parseErrorForInvalidName(Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0, SyntaxKind.OpenBraceToken); return; case "type": - parseErrorForInvalidName(SyntaxKind.EqualsToken, Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0); + parseErrorForInvalidName(Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0, SyntaxKind.EqualsToken); return; } @@ -1640,7 +1612,7 @@ namespace ts { * @param blankDiagnostic Diagnostic to report for the case of the name being blank (matched tokenIfBlankName). * @param nameDiagnostic Diagnostic to report for all other cases. */ - function parseErrorForInvalidName(tokenIfBlankName: SyntaxKind, blankDiagnostic: DiagnosticMessage, nameDiagnostic: DiagnosticMessage) { + function parseErrorForInvalidName(nameDiagnostic: DiagnosticMessage, blankDiagnostic: DiagnosticMessage, tokenIfBlankName: SyntaxKind) { if (token() === tokenIfBlankName) { parseErrorAtCurrentToken(blankDiagnostic); } @@ -1681,13 +1653,31 @@ namespace ts { return; } - return parseSemicolonAfter(SyntaxKind.PropertyDeclaration, name, initializer); + if (tryParseSemicolon()) { + return; + } + + // If an initializer was parsed but there is still an error in finding the next semicolon, + // we generally know there was an error already reported in the initializer... + // class Example { a = new Map([), ) } + // ~ + if (initializer) { + // ...unless we've found the start of a block after a property declaration, in which + // case we can know that regardless of the initializer we should complain on the block. + // class Example { a = 0 {} } + // ~ + if (token() === SyntaxKind.OpenBraceToken) { + parseErrorAtCurrentToken(Diagnostics._0_expected, ";"); + } + + return; + } + + parseErrorForMissingSemicolonAfter(name); } function getExpressionText(expression: Expression | PropertyName) { - return ts.isIdentifier(expression) - ? idText(expression) - : undefined; + return ts.isIdentifier(expression) ? idText(expression) : undefined; } function parseExpectedJSDoc(kind: JSDocSyntaxKind) { @@ -1773,18 +1763,21 @@ namespace ts { return token() === SyntaxKind.CloseBraceToken || token() === SyntaxKind.EndOfFileToken || scanner.hasPrecedingLineBreak(); } - function parseSemicolon(): boolean { - if (canParseSemicolon()) { - if (token() === SyntaxKind.SemicolonToken) { - // consume the semicolon if it was explicitly provided. - nextToken(); - } - - return true; + function tryParseSemicolon() { + if (!canParseSemicolon()) { + return false; } - else { - return parseExpected(SyntaxKind.SemicolonToken); + + if (token() === SyntaxKind.SemicolonToken) { + // consume the semicolon if it was explicitly provided. + nextToken(); } + + return true; + } + + function parseSemicolon(): boolean { + return tryParseSemicolon() || parseExpected(SyntaxKind.SemicolonToken); } function createNodeArray(elements: T[], pos: number, end?: number, hasTrailingComma?: boolean): NodeArray { @@ -5984,7 +5977,9 @@ namespace ts { identifierCount++; expression = finishNode(factory.createIdentifier(""), getNodePos()); } - parseSemicolonAfter(SyntaxKind.Block, expression); + if (!tryParseSemicolon()) { + parseErrorForMissingSemicolonAfter(expression); + } return finishNode(factory.createThrowStatement(expression), pos); } @@ -6045,7 +6040,9 @@ namespace ts { node = factory.createLabeledStatement(expression, parseStatement()); } else { - parseSemicolonAfter(SyntaxKind.Block, expression); + if (!tryParseSemicolon()) { + parseErrorForMissingSemicolonAfter(expression); + } node = factory.createExpressionStatement(expression); if (hasParen) { // do not parse the same jsdoc twice From a052314e052792caf5011700640717a52f9a2392 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 16 Apr 2021 21:44:16 -0400 Subject: [PATCH 14/17] Swap interface name complaints back, and skip new errors on unknown (invalid) tokens --- src/compiler/parser.ts | 15 ++++++++++----- tests/baselines/reference/emitBOM.js | 8 +------- .../invalidUnicodeEscapeSequance3.errors.txt | 8 +------- .../scannerUnexpectedNullCharacter1.errors.txt | Bin 1206 -> 811 bytes 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index de316fe32e70f..b1e3feba0f436 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1577,7 +1577,7 @@ namespace ts { return; case "interface": - parseErrorForInvalidName(Diagnostics.Interface_must_be_given_a_name, Diagnostics.Interface_name_cannot_be_0, SyntaxKind.OpenBraceToken); + parseErrorForInvalidName(Diagnostics.Interface_name_cannot_be_0, Diagnostics.Interface_must_be_given_a_name, SyntaxKind.OpenBraceToken); return; case "is": @@ -1586,11 +1586,11 @@ namespace ts { case "module": case "namespace": - parseErrorForInvalidName(Diagnostics.Namespace_must_be_given_a_name, Diagnostics.Namespace_name_cannot_be_0, SyntaxKind.OpenBraceToken); + parseErrorForInvalidName(Diagnostics.Namespace_name_cannot_be_0, Diagnostics.Namespace_must_be_given_a_name, SyntaxKind.OpenBraceToken); return; case "type": - parseErrorForInvalidName(Diagnostics.Type_alias_must_be_given_a_name, Diagnostics.Type_alias_name_cannot_be_0, SyntaxKind.EqualsToken); + parseErrorForInvalidName(Diagnostics.Type_alias_name_cannot_be_0, Diagnostics.Type_alias_must_be_given_a_name, SyntaxKind.EqualsToken); return; } @@ -1601,16 +1601,21 @@ namespace ts { return; } - // We know this is a slightly more precise case than a missing expected semicolon. + // Unknown tokens are handled with their own errors in the scanner + if (token() === SyntaxKind.Unknown) { + return; + } + + // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. parseErrorAt(pos, node.end, Diagnostics.Unexpected_keyword_or_identifier); } /** * Reports a diagnostic error for the current token being an invalid name. * - * @param tokenIfBlankName Current token if the name was invalid for being blank (not provided / skipped). * @param blankDiagnostic Diagnostic to report for the case of the name being blank (matched tokenIfBlankName). * @param nameDiagnostic Diagnostic to report for all other cases. + * @param tokenIfBlankName Current token if the name was invalid for being blank (not provided / skipped). */ function parseErrorForInvalidName(nameDiagnostic: DiagnosticMessage, blankDiagnostic: DiagnosticMessage, tokenIfBlankName: SyntaxKind) { if (token() === tokenIfBlankName) { diff --git a/tests/baselines/reference/emitBOM.js b/tests/baselines/reference/emitBOM.js index 4717bf52a0b3b..2890ba0d81dbc 100644 --- a/tests/baselines/reference/emitBOM.js +++ b/tests/baselines/reference/emitBOM.js @@ -2,20 +2,14 @@ // JS and d.ts output should have a BOM but not the sourcemap var x; -tests/cases/compiler/emitBOM.js(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/emitBOM.js(1,2): error TS1127: Invalid character. -tests/cases/compiler/emitBOM.js(1,2): error TS1128: Declaration or statement expected. tests/cases/compiler/emitBOM.js(1,3): error TS1127: Invalid character. -==== tests/cases/compiler/emitBOM.js (4 errors) ==== +==== tests/cases/compiler/emitBOM.js (2 errors) ==== // JS and d.ts output should have a BOM but not the sourcemap - ~ -!!! error TS1434: Unexpected keyword or identifier. !!! error TS1127: Invalid character. - ~ -!!! error TS1128: Declaration or statement expected. !!! error TS1127: Invalid character. var x; diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt index da294ddd7b3b7..45674e698b68a 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt @@ -1,19 +1,13 @@ -tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS1434: Unexpected keyword or identifier. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,1): error TS2304: Cannot find name 'a'. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1127: Invalid character. -tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,2): error TS1128: Declaration or statement expected. tests/cases/compiler/invalidUnicodeEscapeSequance3.ts(1,3): error TS2304: Cannot find name 'u'. -==== tests/cases/compiler/invalidUnicodeEscapeSequance3.ts (5 errors) ==== +==== tests/cases/compiler/invalidUnicodeEscapeSequance3.ts (3 errors) ==== a\u ~ -!!! error TS1434: Unexpected keyword or identifier. - ~ !!! error TS2304: Cannot find name 'a'. !!! error TS1127: Invalid character. - ~ -!!! error TS1128: Declaration or statement expected. ~ !!! error TS2304: Cannot find name 'u'. \ No newline at end of file diff --git a/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt b/tests/baselines/reference/scannerUnexpectedNullCharacter1.errors.txt index 739e922ac83e9191bebc004bfe4823f473679bbb..6c9e72240ca31b6cf952736ddab788c0a1a677c6 100644 GIT binary patch delta 31 ncmdnSxteW4?Btm&5)*%)pB%{ao6%&lFSE(y{mh}0Ls*gk&VCFf delta 202 zcmZ3@wvBT_tcszDv5A#JXkKbXL27bIYKlU3YGrwTQHnx-kwRulYF_jnV$zzQ(Tf*l9~%trvNiy;|G66MzhHdOeX5Y7@k_BH#wFm e$E=Q*OHol#A+@LoXlh8Xp`j5mmQCKzlmh?-+(=~r From dd47c39f85cc297a0987f2cdec17dd16863f43f3 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 17 Apr 2021 12:27:07 -0400 Subject: [PATCH 15/17] Used tokenToString, not a raw semicolon --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0da441f00733d..1987fe02f6661 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1672,7 +1672,7 @@ namespace ts { // class Example { a = 0 {} } // ~ if (token() === SyntaxKind.OpenBraceToken) { - parseErrorAtCurrentToken(Diagnostics._0_expected, ";"); + parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); } return; From b878e74c1e499aa80d6843b27ca68f618648917e Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 14 Jul 2021 15:03:37 -0400 Subject: [PATCH 16/17] Inline getExpressionText helper --- src/compiler/parser.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 857f447b17946..597e57d2fb934 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1568,7 +1568,7 @@ namespace ts { } // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. - const expressionText = getExpressionText(node); + const expressionText = ts.isIdentifier(node) ? idText(node) : undefined; if (!expressionText || !isIdentifierText(expressionText, languageVersion)) { parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken)); return; @@ -1693,10 +1693,6 @@ namespace ts { parseErrorForMissingSemicolonAfter(name); } - function getExpressionText(expression: Expression | PropertyName) { - return ts.isIdentifier(expression) ? idText(expression) : undefined; - } - function parseExpectedJSDoc(kind: JSDocSyntaxKind) { if (token() === kind) { nextTokenJSDoc(); From b16d5eb39b391abf45e1ec35f4e054ac37c9de63 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 14 Jul 2021 15:22:09 -0400 Subject: [PATCH 17/17] Remove remarks in src/compiler/parser.ts --- src/compiler/parser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 597e57d2fb934..abfeadb48f970 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1556,7 +1556,6 @@ namespace ts { * known common variants of a missing semicolon, such as from a mispelled names. * * @param node Node preceding the expected semicolon location. - * @remarks */ function parseErrorForMissingSemicolonAfter(node: Expression | PropertyName): void { // Tagged template literals are sometimes used in places where only simple strings are allowed, i.e.: