diff --git a/crates/oxc_parser/src/js/class.rs b/crates/oxc_parser/src/js/class.rs index 135faa37d..051b4acbd 100644 --- a/crates/oxc_parser/src/js/class.rs +++ b/crates/oxc_parser/src/js/class.rs @@ -275,7 +275,7 @@ impl<'a> Parser<'a> { optional, )?; if let Some((name, span)) = definition.prop_name() { - if r#static && name == "prototype" { + if r#static && name == "prototype" && !self.ctx.has_ambient() { self.error(diagnostics::StaticPrototype(span)); } if !r#static && name == "constructor" { @@ -309,7 +309,7 @@ impl<'a> Parser<'a> { if name == "constructor" { self.error(diagnostics::FieldConstructor(span)); } - if r#static && name == "prototype" { + if r#static && name == "prototype" && !self.ctx.has_ambient() { self.error(diagnostics::StaticPrototype(span)); } } diff --git a/tasks/coverage/typescript.snap b/tasks/coverage/typescript.snap index 5460f6491..15ef70c28 100644 --- a/tasks/coverage/typescript.snap +++ b/tasks/coverage/typescript.snap @@ -1,6 +1,6 @@ TypeScript Summary: AST Parsed : 2332/2340 (99.66%) -Positive Passed: 2325/2340 (99.36%) +Positive Passed: 2326/2340 (99.40%) Negative Passed: 681/2532 (26.90%) Expect Syntax Error: "Symbols/ES5SymbolProperty2.ts" Expect Syntax Error: "Symbols/ES5SymbolProperty6.ts" @@ -1866,23 +1866,6 @@ Expect to Parse: "async/es6/asyncWithVarShadowing_es6.ts" · ╰── It can not be redeclared here 134 │ } ╰──── -Expect to Parse: "classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts" - - × Classes may not have a static property named prototype - ╭─[classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts:26:1] - 26 │ declare class StaticPrototype { - 27 │ static prototype: number; // ok - · ───────── - 28 │ prototype: string; // ok - ╰──── - - × Classes may not have a static property named prototype - ╭─[classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts:31:1] - 31 │ declare class StaticPrototypeFn { - 32 │ static prototype: any; // ok - · ───────── - 33 │ prototype(): any; // ok - ╰──── Expect to Parse: "es6/for-ofStatements/for-of53.ts" × Identifier `v` has already been declared