Skip to content

Commit 3bf02c0

Browse files
committed
Handle ? as an optional argument (not ternary)
1 parent 4cf6a2c commit 3bf02c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

common/scanner.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ static bool scan_ternary_qmark(TSLexer *lexer) {
170170

171171
if (lexer->lookahead == '?') return false;
172172

173+
/* TypeScript optional arguments contain the ?: sequence, possibly
174+
with whitespace. */
175+
for(;;) {
176+
if (!iswspace(lexer->lookahead)) break;
177+
skip(lexer);
178+
}
179+
if (lexer->lookahead == ':') return false;
180+
173181
lexer->mark_end(lexer);
174182
lexer->result_symbol = TERNARY_QMARK;
175183

0 commit comments

Comments
 (0)