Skip to content

Commit feb392b

Browse files
committed
TypeScript: skip ! when parsing properties
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent f3d14e3 commit feb392b

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed
File renamed without changes.

Units/parser-typescript.r/github-issue-4384.d/expected.tags renamed to Units/parser-typescript.r/skip-bang.d/expected.tags

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ SomeClass input.ts /^class SomeClass {$/;" c
22
brokenMethod input.ts /^ brokenMethod() {$/;" m class:SomeClass
33
x input.ts /^ const x = {a: !true ? 1 : 2};$/;" C method:SomeClass.brokenMethod
44
missingMethod input.ts /^ missingMethod() {}$/;" m class:SomeClass
5+
C input-0.ts /^class C {$/;" c
6+
foo input-0.ts /^ foo!: string;$/;" p class:C
7+
bar input-0.ts /^ public bar!: number;$/;" p class:C
8+
baz input-0.ts /^ readonly baz!: boolean;$/;" p class:C
9+
constructor input-0.ts /^ constructor() {}$/;" m class:C
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class C {
2+
foo!: string;
3+
public bar!: number;
4+
readonly baz!: boolean;
5+
6+
constructor() {}
7+
}
File renamed without changes.
File renamed without changes.

parsers/typescript.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,9 @@ static void parseConstructorParams (const int classScope, const int constrScope,
16541654
}
16551655

16561656
MULTI_CHAR_PARSER_DEF (ClassBodyChars, "\n,{", TOKEN_NL, TOKEN_COMMA, TOKEN_OPEN_CURLY)
1657-
MULTI_CHAR_PARSER_DEF (ClassBodyAfterCurlyChars, "\n}*@(?:;=-+/^<>.,|&",
1657+
MULTI_CHAR_PARSER_DEF (ClassBodyAfterCurlyChars, "\n}*@(?!:;=-+/^<>.,|&",
16581658
TOKEN_NL, TOKEN_CLOSE_CURLY, TOKEN_STAR, TOKEN_AT, TOKEN_OPEN_PAREN,
1659-
TOKEN_QUESTION_MARK, TOKEN_COLON, TOKEN_SEMICOLON, TOKEN_EQUAL_SIGN,
1659+
TOKEN_QUESTION_MARK, TOKEN_BANG, TOKEN_COLON, TOKEN_SEMICOLON, TOKEN_EQUAL_SIGN,
16601660
TOKEN_MINUS, TOKEN_PLUS, TOKEN_DIV, TOKEN_POWER,
16611661
TOKEN_GREATER, TOKEN_LOWER, TOKEN_PERIOD, TOKEN_COMMA,
16621662
TOKEN_PIPE, TOKEN_AMPERSAND)
@@ -1810,6 +1810,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)
18101810
}
18111811
parsingValue = true;
18121812
break;
1813+
case TOKEN_BANG:
18131814
case TOKEN_QUESTION_MARK:
18141815
break; /* Just consuming the token */
18151816
case TOKEN_COLON:

0 commit comments

Comments
 (0)