diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index b22183b868f83..d6a47fbe6f418 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -374,6 +374,8 @@ impl<'a> Expression<'a> { /// Is identifier or `a.b` expression where `a` is an identifier. pub fn is_entity_name_expression(&self) -> bool { matches!(self.without_parentheses(), Expression::Identifier(_)) + // Special case: treat `this.B` like `this` was an identifier + || matches!(self.without_parentheses(), Expression::ThisExpression(_)) || self.is_property_access_entity_name_expression() } diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index e9f6c0ac0196b..d6e8ea9fba58f 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -2,8 +2,8 @@ commit: 1d4546bc parser_babel Summary: AST Parsed : 2351/2362 (99.53%) -Positive Passed: 2329/2362 (98.60%) -Negative Passed: 1601/1698 (94.29%) +Positive Passed: 2330/2362 (98.65%) +Negative Passed: 1600/1698 (94.23%) Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/invalid-startindex-and-startline-specified-without-startcolumn/input.js Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/startline-and-startcolumn-specified/input.js @@ -134,6 +134,8 @@ Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/ty Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/interface/invalid-modifiers-property/input.ts +Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2/input.ts + Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-disallowed/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-disallowed-babel-7/input.ts @@ -644,16 +646,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ── ╰──── -Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2-babel-7/input.ts - - × TS(2499): An interface can only extend an identifier/qualified-name with optional type arguments. - ╭─[babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2-babel-7/input.ts:3:21] - 2 │ // but they are always type-checking errors. - 3 │ interface A extends this.B {} - · ────── - 4 │ type T = typeof var.bar; - ╰──── - Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts × Expected `,` but found `extends` @@ -12825,14 +12817,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 3 │ } ╰──── - × TS(2499): An interface can only extend an identifier/qualified-name with optional type arguments. - ╭─[babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2/input.ts:3:21] - 2 │ // but they are always type-checking errors. - 3 │ interface A extends this.B {} - · ────── - 4 │ type T = typeof var.bar; - ╰──── - × Identifier `A` has already been declared ╭─[babel/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/input.ts:1:7] 1 │ class A {} diff --git a/tasks/coverage/snapshots/semantic_babel.snap b/tasks/coverage/snapshots/semantic_babel.snap index e3984628d489a..06fcb40263fcd 100644 --- a/tasks/coverage/snapshots/semantic_babel.snap +++ b/tasks/coverage/snapshots/semantic_babel.snap @@ -1428,7 +1428,6 @@ after transform: ["this"] rebuilt : [] semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2-babel-7/input.ts -An interface can only extend an identifier/qualified-name with optional type arguments. Scope children mismatch: after transform: ScopeId(0): [ScopeId(1), ScopeId(2)] rebuilt : ScopeId(0): []