Skip to content

Commit 1b9ea99

Browse files
committed
Resolve TODO
1 parent 964feb1 commit 1b9ea99

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,10 @@
14971497
"category": "Error",
14981498
"code": 1477
14991499
},
1500+
"Identifier or string literal expected.": {
1501+
"category": "Error",
1502+
"code": 1478
1503+
},
15001504

15011505
"The types of '{0}' are incompatible between these types.": {
15021506
"category": "Error",

src/compiler/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,9 @@ namespace ts {
27802780
case ParsingContext.ImportOrExportSpecifiers: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
27812781
case ParsingContext.JsxAttributes: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
27822782
case ParsingContext.JsxChildren: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
2783-
default: return [undefined!]; // TODO: GH#18217 `default: Debug.assertNever(context);`
2783+
case ParsingContext.AssertEntries: return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
2784+
case ParsingContext.Count: return Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
2785+
default: Debug.assertNever(context);
27842786
}
27852787
}
27862788

tests/baselines/reference/parseAssertEntriesError.errors.txt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/index.ts(2,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
2-
/index.ts(2,32): error TS1005: '}' expected.
2+
/index.ts(2,32): error TS1478: Identifier or string literal expected.
33
/index.ts(2,32): error TS2695: Left side of comma operator is unused and has no side effects.
44
/index.ts(2,55): error TS1005: ';' expected.
55
/index.ts(2,66): error TS1128: Declaration or statement expected.
@@ -10,7 +10,7 @@
1010
/index.ts(3,36): error TS1005: ':' expected.
1111
/index.ts(3,70): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'.
1212
/index.ts(5,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
13-
/index.ts(5,59): error TS1005: '}' expected.
13+
/index.ts(5,59): error TS1478: Identifier or string literal expected.
1414
/index.ts(5,59): error TS2695: Left side of comma operator is unused and has no side effects.
1515
/index.ts(5,82): error TS1005: ';' expected.
1616
/index.ts(5,93): error TS1128: Declaration or statement expected.
@@ -21,7 +21,7 @@
2121
/index.ts(5,98): error TS2304: Cannot find name 'RequireInterface'.
2222
/index.ts(5,114): error TS1128: Declaration or statement expected.
2323
/index.ts(6,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
24-
/index.ts(6,59): error TS1005: '}' expected.
24+
/index.ts(6,59): error TS1478: Identifier or string literal expected.
2525
/index.ts(6,59): error TS2695: Left side of comma operator is unused and has no side effects.
2626
/index.ts(6,82): error TS1005: ';' expected.
2727
/index.ts(6,92): error TS1128: Declaration or statement expected.
@@ -39,9 +39,7 @@
3939
~~~~~~~~~~~~~~~~~~~~~~~~~
4040
!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
4141
~~~~
42-
!!! error TS1005: '}' expected.
43-
!!! related TS1007 /index.ts:2:31: The parser expected to find a '}' to match the '{' token here.
44-
!!! related TS1007 /index.ts:2:21: The parser expected to find a '}' to match the '{' token here.
42+
!!! error TS1478: Identifier or string literal expected.
4543
~~~~
4644
!!! error TS2695: Left side of comma operator is unused and has no side effects.
4745
~
@@ -66,9 +64,7 @@
6664
~~~~~~~~~~~~~~~~~~~~~~~~~
6765
!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
6866
~~~~
69-
!!! error TS1005: '}' expected.
70-
!!! related TS1007 /index.ts:5:58: The parser expected to find a '}' to match the '{' token here.
71-
!!! related TS1007 /index.ts:5:48: The parser expected to find a '}' to match the '{' token here.
67+
!!! error TS1478: Identifier or string literal expected.
7268
~~~~
7369
!!! error TS2695: Left side of comma operator is unused and has no side effects.
7470
~
@@ -91,9 +87,7 @@
9187
~~~~~~~~~~~~~~~~~~~~~~~~~
9288
!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'?
9389
~~~~
94-
!!! error TS1005: '}' expected.
95-
!!! related TS1007 /index.ts:6:58: The parser expected to find a '}' to match the '{' token here.
96-
!!! related TS1007 /index.ts:6:48: The parser expected to find a '}' to match the '{' token here.
90+
!!! error TS1478: Identifier or string literal expected.
9791
~~~~
9892
!!! error TS2695: Left side of comma operator is unused and has no side effects.
9993
~

0 commit comments

Comments
 (0)