Skip to content

Commit 484758a

Browse files
author
Andy
authored
Handle ! following a keyword in isClassMemberStart (microsoft#20617)
* Handle `!` following a keyword in isClassMemberStart * Fix test
1 parent b629ff4 commit 484758a

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

src/compiler/parser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5462,6 +5462,7 @@ namespace ts {
54625462
switch (token()) {
54635463
case SyntaxKind.OpenParenToken: // Method declaration
54645464
case SyntaxKind.LessThanToken: // Generic Method declaration
5465+
case SyntaxKind.ExclamationToken: // Non-null assertion on property name
54655466
case SyntaxKind.ColonToken: // Type Annotation for declaration
54665467
case SyntaxKind.EqualsToken: // Initializer for declaration
54675468
case SyntaxKind.QuestionToken: // Not valid, but permitted so that it gets caught later on.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [parserIsClassMemberStart.ts]
2+
class C {
3+
type!: number;
4+
}
5+
6+
7+
//// [parserIsClassMemberStart.js]
8+
var C = /** @class */ (function () {
9+
function C() {
10+
}
11+
return C;
12+
}());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/parserIsClassMemberStart.ts ===
2+
class C {
3+
>C : Symbol(C, Decl(parserIsClassMemberStart.ts, 0, 0))
4+
5+
type!: number;
6+
>type : Symbol(C.type, Decl(parserIsClassMemberStart.ts, 0, 9))
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/parserIsClassMemberStart.ts ===
2+
class C {
3+
>C : C
4+
5+
type!: number;
6+
>type : number
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class C {
2+
type!: number;
3+
}

0 commit comments

Comments
 (0)