Skip to content

Commit 014dc3d

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #48067 (Fix incorrect parser error assumpti...) into release-4.6 (#48068)
Co-authored-by: Jake Bailey <[email protected]>
1 parent 78ee4ca commit 014dc3d

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

‎src/compiler/parser.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -1680,19 +1680,8 @@ namespace ts {
16801680
return;
16811681
}
16821682

1683-
// If an initializer was parsed but there is still an error in finding the next semicolon,
1684-
// we generally know there was an error already reported in the initializer...
1685-
// class Example { a = new Map([), ) }
1686-
// ~
16871683
if (initializer) {
1688-
// ...unless we've found the start of a block after a property declaration, in which
1689-
// case we can know that regardless of the initializer we should complain on the block.
1690-
// class Example { a = 0 {} }
1691-
// ~
1692-
if (token() === SyntaxKind.OpenBraceToken) {
1693-
parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken));
1694-
}
1695-
1684+
parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken));
16961685
return;
16971686
}
16981687

‎tests/baselines/reference/parser0_004152.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,28): error TS2304: Cannot find name 'DisplayPosition'.
22
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,45): error TS1137: Expression or comma expected.
3-
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
3+
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1005: ';' expected.
44
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,49): error TS1005: ';' expected.
55
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,51): error TS2300: Duplicate identifier '3'.
66
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,52): error TS1005: ';' expected.
@@ -41,7 +41,7 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T
4141
~
4242
!!! error TS1137: Expression or comma expected.
4343
~
44-
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
44+
!!! error TS1005: ';' expected.
4545
~
4646
!!! error TS1005: ';' expected.
4747
~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @target: esnext
4+
// @lib: es2015
5+
// @strict: true
6+
7+
//// class C {
8+
//// map = new Set<string, number>/*$*/
9+
////
10+
//// foo() {
11+
////
12+
//// }
13+
//// }
14+
15+
goTo.marker('$');
16+
edit.insert('()');
17+
verify.getSyntacticDiagnostics([]);

0 commit comments

Comments
 (0)