Skip to content

Commit b80b256

Browse files
committed
refactor(fe): remove special handling for keywords in JSX
As of the previous commit, we now always use skip_in_jsx() instead of skip(), therefore we never see kw_as, etc. when parsing a JSX attribute name.
1 parent f3e639a commit b80b256

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/quick-lint-js/fe/parse-expression.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,13 +3818,13 @@ Expression* Parser::parse_jsx_element_or_fragment(Parse_Visitor_Base& v,
38183818

38193819
next_attribute:
38203820
switch (this->peek().type) {
3821-
// NOTE[JSX-keyword-after-TypeScript-generic]: Normally, JS/TS keywords would
3822-
// appear as Token_Type::identifier here. However, when parsing
3823-
// '<C<T> class="" />' in TypeScript, the 'class' following '>' is parsed as a
3824-
// keyword. This is because parse_and_visit_typescript_generic_arguments calls
3825-
// this->skip() rather than this->skip_in_jsx(). That's why we need to check
3826-
// for keywords here.
38273821
QLJS_CASE_KEYWORD:
3822+
// JS/TS keywords should not happen here because skip_in_jsx() should have
3823+
// been called.
3824+
QLJS_ASSERT(false);
3825+
goto identifier_attribute_name;
3826+
3827+
identifier_attribute_name:
38283828
case Token_Type::identifier: {
38293829
Identifier attribute = this->peek().identifier_name();
38303830
bool has_namespace = false;

test/test-parse-typescript-generic.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ TEST_F(Test_Parse_TypeScript_Generic, jsx_element) {
910910

911911
{
912912
// 'as' should be treated as an attribute name, not a keyword.
913-
// See NOTE[JSX-keyword-after-TypeScript-generic].
914913
Test_Parser p(u8"<C<T> as={value} />"_sv, typescript_jsx_options);
915914
Expression* ast = p.parse_expression();
916915
EXPECT_EQ(summarize(ast), "jsxelement(C, var value)");

0 commit comments

Comments
 (0)