From c141447ee7a0a32ca24ba70c17537caa7e29f334 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 31 Mar 2021 10:12:46 -0700 Subject: [PATCH 1/4] Only issue matching token errors on non-dupe locations Intead of unconditionally retrieving the last error and attaching a related span, `parseErrorAt` and friends now return the last error and return `false` when there is none. Also make one more place use parseExpectedMatchingBrackets that I missed last time. --- src/compiler/parser.ts | 71 +++++++++++-------- ...torWithIncompleteTypeAnnotation.errors.txt | 1 - ...tructuringParameterDeclaration2.errors.txt | 1 - ...thDotFollowedByNamespaceKeyword.errors.txt | 3 +- .../nestedClassDeclaration.errors.txt | 1 - .../objectLiteralWithSemicolons4.errors.txt | 3 +- .../objectSpreadNegativeParse.errors.txt | 1 - .../parseErrorIncorrectReturnToken.errors.txt | 1 - ...RecoveryArrayLiteralExpression3.errors.txt | 1 - .../reference/parserFuzz1.errors.txt | 3 +- .../reference/reservedWords2.errors.txt | 1 - .../syntax-errors-with-incremental.js | 10 --- .../initial-build/syntax-errors.js | 10 --- ...mit-any-files-on-error-with-incremental.js | 10 --- .../does-not-emit-any-files-on-error.js | 10 --- .../with-noEmitOnError-syntax-errors.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../default/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../defaultAndD/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../incremental/default/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../defaultAndD/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../isolatedModules/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../isolatedModulesAndD/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../isolatedModules/with-noEmitOnError.js | 10 --- .../with-noEmitOnError-with-incremental.js | 10 --- .../isolatedModulesAndD/with-noEmitOnError.js | 10 --- 40 files changed, 44 insertions(+), 333 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index de0bb9c402236..fd769f916e0aa 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1335,24 +1335,30 @@ namespace ts { return inContext(NodeFlags.AwaitContext); } - function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void { - parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); + function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { + return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } - function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): void { + function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { // Don't report another error if it would just be at the same position as the last error. const lastError = lastOrUndefined(parseDiagnostics); + let result: DiagnosticWithDetachedLocation | false; if (!lastError || start !== lastError.start) { - parseDiagnostics.push(createDetachedDiagnostic(fileName, start, length, message, arg0)); + result = createDetachedDiagnostic(fileName, start, length, message, arg0) + parseDiagnostics.push(result); + } + else { + result = false; } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; + return result } - function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): void { - parseErrorAtPosition(start, end - start, message, arg0); + function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { + return parseErrorAtPosition(start, end - start, message, arg0); } function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void { @@ -1533,6 +1539,24 @@ namespace ts { return false; } + /** Like parseExpected, but returns true=succeed, diagnostic=fail, false=fail+failed to log error */ + function parseTokenForError(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage, shouldAdvance = true): DiagnosticWithDetachedLocation | boolean { + if (token() === kind) { + if (shouldAdvance) { + nextToken(); + } + return true; + } + + // Report specific message if provided with one. Otherwise, report generic fallback message. + if (diagnosticMessage) { + return parseErrorAtCurrentToken(diagnosticMessage); + } + else { + return parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind)); + } + } + function parseExpectedJSDoc(kind: JSDocSyntaxKind) { if (token() === kind) { nextTokenJSDoc(); @@ -1543,17 +1567,16 @@ namespace ts { } function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) { - if (!parseExpected(closeKind)) { - const lastError = lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === Diagnostics._0_expected.code) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind)) - ); - } + const lastError = parseTokenForError(closeKind); + if (typeof lastError === 'boolean') + return lastError + else { + addRelatedInfo( + lastError, + createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind)) + ); return false; } - return true; } function parseOptional(t: SyntaxKind): boolean { @@ -5513,15 +5536,7 @@ namespace ts { parseExpected(SyntaxKind.OpenBraceToken); const multiLine = scanner.hasPrecedingLineBreak(); const properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(SyntaxKind.CloseBraceToken)) { - const lastError = lastOrUndefined(parseDiagnostics); - if (lastError && lastError.code === Diagnostics._0_expected.code) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(SyntaxKind.OpenBraceToken), tokenToString(SyntaxKind.CloseBraceToken)) - ); - } - } + parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } @@ -7984,13 +7999,9 @@ namespace ts { hasChildren = true; if (child.kind === SyntaxKind.JSDocTypeTag) { if (childTypeTag) { - parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); - const lastError = lastOrUndefined(parseDiagnostics); + const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { - addRelatedInfo( - lastError, - createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here) - ); + addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here)); } break; } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 9a3e9d8136897..4e866e9e9e82f 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -505,7 +505,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1135: Argument expression expected. ~ !!! error TS1005: '(' expected. -!!! related TS1007 tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts:257:33: The parser expected to find a ')' to match the '(' token here. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~~~ diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 02dde837f351a..c1c79a2300d26 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -39,7 +39,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2322: Type 'string' is not assignable to type 'number'. ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:7:4: The parser expected to find a ']' to match the '[' token here. a0([1, 2, [["world"]], "string"]); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. diff --git a/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt b/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt index 3a7c89e2f4157..6bac67291472c 100644 --- a/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt +++ b/tests/baselines/reference/errorRecoveryWithDotFollowedByNamespaceKeyword.errors.txt @@ -16,5 +16,4 @@ tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts(9,2): err } !!! error TS1005: '}' expected. -!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here. -!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:2:20: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file diff --git a/tests/baselines/reference/nestedClassDeclaration.errors.txt b/tests/baselines/reference/nestedClassDeclaration.errors.txt index 5540ee024378d..f897c38d68191 100644 --- a/tests/baselines/reference/nestedClassDeclaration.errors.txt +++ b/tests/baselines/reference/nestedClassDeclaration.errors.txt @@ -32,7 +32,6 @@ tests/cases/conformance/classes/nestedClassDeclaration.ts(17,1): error TS1128: D !!! error TS2304: Cannot find name 'C4'. ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/classes/nestedClassDeclaration.ts:14:9: The parser expected to find a '}' to match the '{' token here. } } ~ diff --git a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt index 651c0b66df75c..544bddafff278 100644 --- a/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt +++ b/tests/baselines/reference/objectLiteralWithSemicolons4.errors.txt @@ -9,5 +9,4 @@ tests/cases/compiler/objectLiteralWithSemicolons4.ts(3,1): error TS1005: ',' exp !!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer. ; ~ -!!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/compiler/objectLiteralWithSemicolons4.ts:1:9: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index 692fb7617da63..b37200c4f0293 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -28,7 +28,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error T !!! error TS2304: Cannot find name 'matchMedia'. ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts:3:10: The parser expected to find a '}' to match the '{' token here. ~ !!! error TS1128: Declaration or statement expected. let o10 = { ...get x() { return 12; }}; diff --git a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt index bc43cd5b7763b..2cf728848e45e 100644 --- a/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt +++ b/tests/baselines/reference/parseErrorIncorrectReturnToken.errors.txt @@ -25,7 +25,6 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Decl m(n: number) => string { ~~ !!! error TS1005: '{' expected. -!!! related TS1007 tests/cases/compiler/parseErrorIncorrectReturnToken.ts:8:9: The parser expected to find a '}' to match the '{' token here. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ diff --git a/tests/baselines/reference/parserErrorRecoveryArrayLiteralExpression3.errors.txt b/tests/baselines/reference/parserErrorRecoveryArrayLiteralExpression3.errors.txt index 9de5aa8014cfb..eb32618af4bbf 100644 --- a/tests/baselines/reference/parserErrorRecoveryArrayLiteralExpression3.errors.txt +++ b/tests/baselines/reference/parserErrorRecoveryArrayLiteralExpression3.errors.txt @@ -8,7 +8,6 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions var texCoords = [2, 2, 0.5000001192092895, 0.8749999 ; 403953552, 0.5000001192092895, 0.8749999403953552]; ~ !!! error TS1005: ',' expected. -!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression3.ts:1:17: The parser expected to find a ']' to match the '[' token here. ~~~~~~~~~ !!! error TS2695: Left side of comma operator is unused and has no side effects. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/parserFuzz1.errors.txt b/tests/baselines/reference/parserFuzz1.errors.txt index e11d25c48fa56..e90dda55244e6 100644 --- a/tests/baselines/reference/parserFuzz1.errors.txt +++ b/tests/baselines/reference/parserFuzz1.errors.txt @@ -20,5 +20,4 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): e ~~~~~~ !!! error TS1005: ';' expected. -!!! error TS1005: '{' expected. -!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts:1:9: The parser expected to find a '}' to match the '{' token here. \ No newline at end of file +!!! error TS1005: '{' expected. \ No newline at end of file diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 7c078493e8d9d..6ecb9471631bd 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -105,7 +105,6 @@ tests/cases/compiler/reservedWords2.ts(12,17): error TS1138: Parameter declarati !!! error TS1005: ';' expected. ~ !!! error TS1005: '(' expected. -!!! related TS1007 tests/cases/compiler/reservedWords2.ts:9:18: The parser expected to find a ')' to match the '(' token here. ~ !!! error TS1128: Declaration or statement expected. enum void {} diff --git a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js index e6fd723a287e3..43e04e41056ac 100644 --- a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js +++ b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors-with-incremental.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -81,11 +76,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js index 4c55b9ce60f7f..e9ea12ea0d3e4 100644 --- a/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js +++ b/tests/baselines/reference/tsbuild/noEmitOnError/initial-build/syntax-errors.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -81,11 +76,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js index a05c649643c1b..8ad612bca9b1c 100644 --- a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js +++ b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js @@ -56,11 +56,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:35 AM] Found 1 error. Watching for file changes. @@ -113,11 +108,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:42 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js index 3e563e8f60930..6af8477219c81 100644 --- a/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js +++ b/tests/baselines/reference/tsbuild/watchMode/noEmitOnError/does-not-emit-any-files-on-error.js @@ -56,11 +56,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:35 AM] Found 1 error. Watching for file changes. @@ -113,11 +108,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:42 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js b/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js index c539e3763b42a..61a42c07f86dc 100644 --- a/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js +++ b/tests/baselines/reference/tsc/incremental/initial-build/with-noEmitOnError-syntax-errors.js @@ -47,11 +47,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. @@ -166,11 +161,6 @@ Output:: 4 ;   ~ - src/src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - Found 1 error. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js index 682a68af31e6c..97c078125158d 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js index 17c877f6ac1a6..16681988e8f32 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js index 0e63864873c02..9b41d9d091312 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js index 9c9b6f756c1bc..bae815eebebfb 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js index 46b48bf4ce507..3994e2409834b 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js index fbb7a7ed57463..da78efc9fba32 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -110,11 +105,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js index ba168ab833f26..95da55bc5839d 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js index 442f3d18610b8..3c0a5fcd89b5c 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js index 13cfbf7708d44..eaea5f602e655 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js index 4a82b0f24e534..105964812e7f4 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js index 101a14226d214..874eff425a3aa 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js index c90e071624ba1..bc6607b8d5347 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js index 73fb8a3f99ede..1f04fa2e6661e 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError-with-incremental.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js index 928db04fad6b8..8d6647dbc4d23 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/default/with-noEmitOnError.js @@ -49,11 +49,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -191,11 +186,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js index e2394ec315283..29b3348f4df39 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js index accbfbc36e434..0a5da71c0d0bd 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/defaultAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js index 22e73f151f5fe..ea636a1de955d 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js index 59fc6a820f087..62bccd4b4e171 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModules/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js index ea3425d143dd8..ebda20c91cd0d 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js index ddff239e3c937..81d203d04cd18 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/incremental/isolatedModulesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js index daf7e2b9e0f2d..18759a8a9c66a 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -186,11 +181,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js index 4093ad4830287..48c8bcb5bd307 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js index b6323d2ed8049..27bfca04dbd53 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. @@ -187,11 +182,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:44 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js index 659ad65715340..0969d50832bf8 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js @@ -43,11 +43,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:32 AM] Found 1 error. Watching for file changes. @@ -104,11 +99,6 @@ Output:: 4 ;   ~ - src/main.ts:2:11 - 2 const a = { -    ~ - The parser expected to find a '}' to match the '{' token here. - [12:00:37 AM] Found 1 error. Watching for file changes. From 723616f2c8a7ff32561cc7f706c9a50348e592b2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 31 Mar 2021 10:35:38 -0700 Subject: [PATCH 2/4] Inline parseTokenForError, return undefined not false --- src/compiler/parser.ts | 44 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fd769f916e0aa..220756ed71db3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1335,29 +1335,29 @@ namespace ts { return inContext(NodeFlags.AwaitContext); } - function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { + function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); } - function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { + function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { // Don't report another error if it would just be at the same position as the last error. const lastError = lastOrUndefined(parseDiagnostics); - let result: DiagnosticWithDetachedLocation | false; + let result: DiagnosticWithDetachedLocation | undefined; if (!lastError || start !== lastError.start) { - result = createDetachedDiagnostic(fileName, start, length, message, arg0) + result = createDetachedDiagnostic(fileName, start, length, message, arg0); parseDiagnostics.push(result); } else { - result = false; + result = undefined; } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. parseErrorBeforeNextFinishedNode = true; - return result + return result; } - function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | false { + function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined { return parseErrorAtPosition(start, end - start, message, arg0); } @@ -1539,24 +1539,6 @@ namespace ts { return false; } - /** Like parseExpected, but returns true=succeed, diagnostic=fail, false=fail+failed to log error */ - function parseTokenForError(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage, shouldAdvance = true): DiagnosticWithDetachedLocation | boolean { - if (token() === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - - // Report specific message if provided with one. Otherwise, report generic fallback message. - if (diagnosticMessage) { - return parseErrorAtCurrentToken(diagnosticMessage); - } - else { - return parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind)); - } - } - function parseExpectedJSDoc(kind: JSDocSyntaxKind) { if (token() === kind) { nextTokenJSDoc(); @@ -1567,16 +1549,18 @@ namespace ts { } function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) { - const lastError = parseTokenForError(closeKind); - if (typeof lastError === 'boolean') - return lastError - else { + if (token() === closeKind) { + nextToken(); + return true; + } + const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind)); + if (lastError) { addRelatedInfo( lastError, createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind)) ); - return false; } + return false; } function parseOptional(t: SyntaxKind): boolean { From 435c99dca5338f8cfa7621a6f0b61c5465ea9d8e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 31 Mar 2021 10:38:43 -0700 Subject: [PATCH 3/4] skip redundant undefined assignment --- src/compiler/parser.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 220756ed71db3..cf371a7655deb 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1347,9 +1347,6 @@ namespace ts { result = createDetachedDiagnostic(fileName, start, length, message, arg0); parseDiagnostics.push(result); } - else { - result = undefined; - } // Mark that we've encountered an error. We'll set an appropriate bit on the next // node we finish so that it can't be reused incrementally. From ed04130a04ce31ec4741ece16ea6bf01db17910f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:03:47 -0700 Subject: [PATCH 4/4] address PR comments --- src/compiler/parser.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index cf371a7655deb..e951178c1a8d4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1548,7 +1548,7 @@ namespace ts { function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) { if (token() === closeKind) { nextToken(); - return true; + return; } const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind)); if (lastError) { @@ -1557,7 +1557,6 @@ namespace ts { createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind)) ); } - return false; } function parseOptional(t: SyntaxKind): boolean {