From 4c2e139a2c36f04b1c306fd598681ead8010de7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:53:50 +0000 Subject: [PATCH 1/8] Initial plan From 55903cd4739a0a6fc1cd6cefbc917b8148b700e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:02:39 +0000 Subject: [PATCH 2/8] Changes before error encountered Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- crates/oxc_parser/src/modifiers.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/oxc_parser/src/modifiers.rs b/crates/oxc_parser/src/modifiers.rs index e9f98912eb929..b34b02915d93a 100644 --- a/crates/oxc_parser/src/modifiers.rs +++ b/crates/oxc_parser/src/modifiers.rs @@ -331,10 +331,9 @@ impl<'a> ParserImpl<'a> { self.bump_any(); let modifier = self.modifier(kind, self.end_span(span)); if modifier.kind == ModifierKind::Export { - self.error(diagnostics::modifier_must_precede_other_modifier( - &modifier, - ModifierKind::Declare, - )); + self.error(diagnostics::modifier_already_seen(&modifier)); + // Don't add the duplicate export modifier to the list + continue; } self.check_for_duplicate_modifiers(flags, &modifier); flags.set(modifier_flags, true); From 658305458139f32370dded6e199ddcd0e52cddaf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:14:15 +0000 Subject: [PATCH 3/8] Fix duplicate export modifier diagnostic message - Changed diagnostic from "export modifier must precede declare modifier" to "export modifier already seen" - Skip adding duplicate export modifier to the modifiers list to avoid secondary validation error - Add test case for duplicate export modifier - Handle empty modifiers case when all modifiers are skipped Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- crates/oxc_parser/src/modifiers.rs | 6 +++++- tasks/coverage/misc/fail/duplicate-export-modifier.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tasks/coverage/misc/fail/duplicate-export-modifier.ts diff --git a/crates/oxc_parser/src/modifiers.rs b/crates/oxc_parser/src/modifiers.rs index b34b02915d93a..50ceb10757937 100644 --- a/crates/oxc_parser/src/modifiers.rs +++ b/crates/oxc_parser/src/modifiers.rs @@ -339,7 +339,11 @@ impl<'a> ParserImpl<'a> { flags.set(modifier_flags, true); modifiers.push(modifier); } - Modifiers::new(Some(modifiers), flags) + if modifiers.is_empty() { + Modifiers::empty() + } else { + Modifiers::new(Some(modifiers), flags) + } } fn at_modifier(&mut self) -> bool { diff --git a/tasks/coverage/misc/fail/duplicate-export-modifier.ts b/tasks/coverage/misc/fail/duplicate-export-modifier.ts new file mode 100644 index 0000000000000..f03496263826d --- /dev/null +++ b/tasks/coverage/misc/fail/duplicate-export-modifier.ts @@ -0,0 +1,2 @@ +export export function foo() { +} From dcb572571f5ac57e9949d4b94bd93b372db1bd80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:56:41 +0000 Subject: [PATCH 4/8] Update snapshots after fixing duplicate export modifier diagnostic - Updated parser_misc.snap to include new test case - Updated parser_typescript.snap to reflect correct diagnostic message Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- tasks/coverage/snapshots/parser_misc.snap | 10 +- .../coverage/snapshots/parser_typescript.snap | 175 ++++-------------- 2 files changed, 43 insertions(+), 142 deletions(-) diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index e5d9e5d5f6406..74131bc42e915 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: AST Parsed : 51/51 (100.00%) Positive Passed: 51/51 (100.00%) -Negative Passed: 118/118 (100.00%) +Negative Passed: 119/119 (100.00%) × Cannot assign to 'arguments' in strict mode ╭─[misc/fail/arguments-eval.ts:1:10] @@ -72,6 +72,14 @@ Negative Passed: 118/118 (100.00%) If you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased. If you have nested conflicts, resolve the outermost conflict first. + × TS(1030): 'export' modifier already seen. + ╭─[misc/fail/duplicate-export-modifier.ts:1:8] + 1 │ export export function foo() { + · ────── + 2 │ } + ╰──── + help: Remove the duplicate modifier. + × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[misc/fail/escape-00.js:1:25] 1 │ export const escape00 = "\00"; diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index 6480771ae33e7..5f6b3781e8d35 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -6082,175 +6082,95 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va · ──────────────── ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:2:12] 1 │ namespace M { 2 │ export export var x = 1; · ────── 3 │ export export function f() { } ╰──── + help: Remove the duplicate modifier. - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:2:12] - 1 │ namespace M { - 2 │ export export var x = 1; - · ────── - 3 │ export export function f() { } - ╰──── - help: Only 'declare' modifier is allowed here. - - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:3:12] - 2 │ export export var x = 1; - 3 │ export export function f() { } - · ────── - 4 │ - ╰──── - - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:3:12] 2 │ export export var x = 1; 3 │ export export function f() { } · ────── 4 │ ╰──── - help: Allowed modifiers are: declare, async + help: Remove the duplicate modifier. - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:5:12] 4 │ 5 │ export export namespace N { · ────── 6 │ export export class C { } ╰──── + help: Remove the duplicate modifier. - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:6:16] - 5 │ export export namespace N { - 6 │ export export class C { } - · ────── - 7 │ export export interface I { } - ╰──── - - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:6:16] 5 │ export export namespace N { 6 │ export export class C { } · ────── 7 │ export export interface I { } ╰──── - help: Allowed modifiers are: declare, abstract - - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:7:16] - 6 │ export export class C { } - 7 │ export export interface I { } - · ────── - 8 │ } - ╰──── + help: Remove the duplicate modifier. - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:7:16] 6 │ export export class C { } 7 │ export export interface I { } · ────── 8 │ } ╰──── - help: Only 'declare' modifier is allowed here. - - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:5:12] - 4 │ - 5 │ export export namespace N { - · ────── - 6 │ export export class C { } - ╰──── - help: Only 'declare' modifier is allowed here. - - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:12:12] - 11 │ declare namespace A { - 12 │ export export var x; - · ────── - 13 │ export export function f() - ╰──── + help: Remove the duplicate modifier. - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:12:12] 11 │ declare namespace A { 12 │ export export var x; · ────── 13 │ export export function f() ╰──── - help: Only 'declare' modifier is allowed here. - - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:13:12] - 12 │ export export var x; - 13 │ export export function f() - · ────── - 14 │ - ╰──── + help: Remove the duplicate modifier. - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:13:12] 12 │ export export var x; 13 │ export export function f() · ────── 14 │ ╰──── - help: Allowed modifiers are: declare, async + help: Remove the duplicate modifier. - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:15:12] 14 │ 15 │ export export namespace N { · ────── 16 │ export export class C { } ╰──── + help: Remove the duplicate modifier. - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:16:16] - 15 │ export export namespace N { - 16 │ export export class C { } - · ────── - 17 │ export export interface I { } - ╰──── - - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:16:16] 15 │ export export namespace N { 16 │ export export class C { } · ────── 17 │ export export interface I { } ╰──── - help: Allowed modifiers are: declare, abstract - - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:17:16] - 16 │ export export class C { } - 17 │ export export interface I { } - · ────── - 18 │ } - ╰──── + help: Remove the duplicate modifier. - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:17:16] 16 │ export export class C { } 17 │ export export interface I { } · ────── 18 │ } ╰──── - help: Only 'declare' modifier is allowed here. - - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:15:12] - 14 │ - 15 │ export export namespace N { - · ────── - 16 │ export export class C { } - ╰──── - help: Only 'declare' modifier is allowed here. + help: Remove the duplicate modifier. × Unexpected token ╭─[typescript/tests/cases/compiler/exportAssignmentWithDeclareAndExportModifiers.ts:2:16] @@ -6600,13 +6520,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 3 │ export function f() { } ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/functionsWithModifiersInBlocks1.ts:4:12] 3 │ export function f() { } 4 │ declare export function f() { } · ────── 5 │ } ╰──── + help: Remove the duplicate modifier. × TS(1183): An implementation cannot be declared in ambient contexts. ╭─[typescript/tests/cases/compiler/functionsWithModifiersInBlocks1.ts:4:32] @@ -6616,15 +6537,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 5 │ } ╰──── - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/compiler/functionsWithModifiersInBlocks1.ts:4:12] - 3 │ export function f() { } - 4 │ declare export function f() { } - · ────── - 5 │ } - ╰──── - help: Allowed modifiers are: declare, async - × Unexpected token ╭─[typescript/tests/cases/compiler/genericCallWithoutArgs.ts:4:18] 3 │ @@ -6753,21 +6665,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 2 │ ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/importDeclWithDeclareModifier.ts:5:9] 4 │ } 5 │ declare export import a = x.c; · ────── 6 │ var b: a; ╰──── + help: Remove the duplicate modifier. - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/importDeclWithDeclareModifierInAmbientContext.ts:6:13] 5 │ } 6 │ declare export import a = x.c; · ────── 7 │ var b: a; ╰──── + help: Remove the duplicate modifier. × Cannot use import statement outside a module ╭─[typescript/tests/cases/compiler/importDeclarationInModuleDeclaration2.ts:2:5] @@ -9663,22 +9577,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va · ────── ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. - ╭─[typescript/tests/cases/compiler/privacyImportParseErrors.ts:326:9] - 325 │ - 326 │ declare export module "anotherParseError2" { - · ────── - 327 │ namespace m2 { - ╰──── - - × 'export' modifier cannot be used here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/privacyImportParseErrors.ts:326:9] 325 │ 326 │ declare export module "anotherParseError2" { · ────── 327 │ namespace m2 { ╰──── - help: Only 'declare' modifier is allowed here. + help: Remove the duplicate modifier. × Unexpected token ╭─[typescript/tests/cases/compiler/privateNameJsx.tsx:4:22] @@ -19591,13 +19497,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va · ╰── Opened here ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/conformance/externalModules/umd-errors.ts:3:8] 2 │ export var p; 3 │ static export as namespace oo1; · ────── 4 │ declare export as namespace oo2; ╰──── + help: Remove the duplicate modifier. × Unexpected token ╭─[typescript/tests/cases/conformance/externalModules/umd-errors.ts:3:15] @@ -22077,20 +21984,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Only 'declare' modifier is allowed here. - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts:1:8] 1 │ export export interface I { · ────── 2 │ } ╰──── - - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts:1:8] - 1 │ export export interface I { - · ────── - 2 │ } - ╰──── - help: Only 'declare' modifier is allowed here. + help: Remove the duplicate modifier. × TS(2414): Interface name cannot be 'string' ╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration8.ts:1:11] @@ -22592,20 +22492,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 3 │ } ╰──── - × TS(1029): 'export' modifier must precede 'declare' modifier. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts:1:8] 1 │ export export class Foo { · ────── 2 │ public Bar() { ╰──── - - × 'export' modifier cannot be used here. - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts:1:8] - 1 │ export export class Foo { - · ────── - 2 │ public Bar() { - ╰──── - help: Allowed modifiers are: declare, abstract + help: Remove the duplicate modifier. × The keyword 'static' is reserved ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts:2:18] From dfb8cfc86b0ecfc269d7450bf8f10cac3315d63d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 15:10:37 +0000 Subject: [PATCH 5/8] Address review feedback: simplify modifier handling Remove unnecessary empty check and continue statement. The check for at_modifier() on line 322 ensures modifiers is never empty when we reach the Modifiers::new() call. Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- crates/oxc_parser/src/modifiers.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/oxc_parser/src/modifiers.rs b/crates/oxc_parser/src/modifiers.rs index 50ceb10757937..f8835b4fc0a3c 100644 --- a/crates/oxc_parser/src/modifiers.rs +++ b/crates/oxc_parser/src/modifiers.rs @@ -332,18 +332,12 @@ impl<'a> ParserImpl<'a> { let modifier = self.modifier(kind, self.end_span(span)); if modifier.kind == ModifierKind::Export { self.error(diagnostics::modifier_already_seen(&modifier)); - // Don't add the duplicate export modifier to the list - continue; } self.check_for_duplicate_modifiers(flags, &modifier); flags.set(modifier_flags, true); modifiers.push(modifier); } - if modifiers.is_empty() { - Modifiers::empty() - } else { - Modifiers::new(Some(modifiers), flags) - } + Modifiers::new(Some(modifiers), flags) } fn at_modifier(&mut self) -> bool { From c300b1c805b658b425c8c04d5fcad6a871a91a76 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:53:50 +0000 Subject: [PATCH 6/8] Initial plan From 8da526abdbe4504bfe8810404c59f5a20cdceca2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 15:16:16 +0000 Subject: [PATCH 7/8] Update snapshots after rebase and conformance run Snapshots now include both diagnostic messages: 1. TS(1030): 'export' modifier already seen (correct) 2. 'export' modifier cannot be used here (secondary validation) Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- tasks/coverage/snapshots/parser_misc.snap | 8 ++ .../coverage/snapshots/parser_typescript.snap | 124 ++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 74131bc42e915..3c6d1aed1029a 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -80,6 +80,14 @@ Negative Passed: 119/119 (100.00%) ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[misc/fail/duplicate-export-modifier.ts:1:8] + 1 │ export export function foo() { + · ────── + 2 │ } + ╰──── + help: Allowed modifiers are: declare, async + × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[misc/fail/escape-00.js:1:25] 1 │ export const escape00 = "\00"; diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index 5f6b3781e8d35..b04719aa944cd 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -6091,6 +6091,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:2:12] + 1 │ namespace M { + 2 │ export export var x = 1; + · ────── + 3 │ export export function f() { } + ╰──── + help: Only 'declare' modifier is allowed here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:3:12] 2 │ export export var x = 1; @@ -6100,6 +6109,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:3:12] + 2 │ export export var x = 1; + 3 │ export export function f() { } + · ────── + 4 │ + ╰──── + help: Allowed modifiers are: declare, async + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:5:12] 4 │ @@ -6118,6 +6136,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:6:16] + 5 │ export export namespace N { + 6 │ export export class C { } + · ────── + 7 │ export export interface I { } + ╰──── + help: Allowed modifiers are: declare, abstract + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:7:16] 6 │ export export class C { } @@ -6127,6 +6154,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:7:16] + 6 │ export export class C { } + 7 │ export export interface I { } + · ────── + 8 │ } + ╰──── + help: Only 'declare' modifier is allowed here. + + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:5:12] + 4 │ + 5 │ export export namespace N { + · ────── + 6 │ export export class C { } + ╰──── + help: Only 'declare' modifier is allowed here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:12:12] 11 │ declare namespace A { @@ -6136,6 +6181,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:12:12] + 11 │ declare namespace A { + 12 │ export export var x; + · ────── + 13 │ export export function f() + ╰──── + help: Only 'declare' modifier is allowed here. + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:13:12] 12 │ export export var x; @@ -6145,6 +6199,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:13:12] + 12 │ export export var x; + 13 │ export export function f() + · ────── + 14 │ + ╰──── + help: Allowed modifiers are: declare, async + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:15:12] 14 │ @@ -6163,6 +6226,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:16:16] + 15 │ export export namespace N { + 16 │ export export class C { } + · ────── + 17 │ export export interface I { } + ╰──── + help: Allowed modifiers are: declare, abstract + × TS(1030): 'export' modifier already seen. ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:17:16] 16 │ export export class C { } @@ -6172,6 +6244,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:17:16] + 16 │ export export class C { } + 17 │ export export interface I { } + · ────── + 18 │ } + ╰──── + help: Only 'declare' modifier is allowed here. + + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:15:12] + 14 │ + 15 │ export export namespace N { + · ────── + 16 │ export export class C { } + ╰──── + help: Only 'declare' modifier is allowed here. + × Unexpected token ╭─[typescript/tests/cases/compiler/exportAssignmentWithDeclareAndExportModifiers.ts:2:16] 1 │ var x; @@ -6537,6 +6627,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 5 │ } ╰──── + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/functionsWithModifiersInBlocks1.ts:4:12] + 3 │ export function f() { } + 4 │ declare export function f() { } + · ────── + 5 │ } + ╰──── + help: Allowed modifiers are: declare, async + × Unexpected token ╭─[typescript/tests/cases/compiler/genericCallWithoutArgs.ts:4:18] 3 │ @@ -9586,6 +9685,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/privacyImportParseErrors.ts:326:9] + 325 │ + 326 │ declare export module "anotherParseError2" { + · ────── + 327 │ namespace m2 { + ╰──── + help: Only 'declare' modifier is allowed here. + × Unexpected token ╭─[typescript/tests/cases/compiler/privateNameJsx.tsx:4:22] 3 │ render() { @@ -21992,6 +22100,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts:1:8] + 1 │ export export interface I { + · ────── + 2 │ } + ╰──── + help: Only 'declare' modifier is allowed here. + × TS(2414): Interface name cannot be 'string' ╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration8.ts:1:11] 1 │ interface string { @@ -22500,6 +22616,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Remove the duplicate modifier. + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts:1:8] + 1 │ export export class Foo { + · ────── + 2 │ public Bar() { + ╰──── + help: Allowed modifiers are: declare, abstract + × The keyword 'static' is reserved ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331.ts:2:18] 1 │ class test { From bfe7c7381cdb8bc084a62efeea7cf35f689d5a58 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 15:20:16 +0000 Subject: [PATCH 8/8] Add test cases for declare-before-export and duplicate-declare modifiers - declare-before-export-modifier.ts: Tests `declare export function foo() {}` - duplicate-declare-modifier.ts: Tests `declare declare function foo() {}` Both produce correct TS(1030) diagnostics for duplicate modifiers. Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- .../fail/declare-before-export-modifier.ts | 1 + .../misc/fail/duplicate-declare-modifier.ts | 1 + tasks/coverage/snapshots/parser_misc.snap | 35 ++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tasks/coverage/misc/fail/declare-before-export-modifier.ts create mode 100644 tasks/coverage/misc/fail/duplicate-declare-modifier.ts diff --git a/tasks/coverage/misc/fail/declare-before-export-modifier.ts b/tasks/coverage/misc/fail/declare-before-export-modifier.ts new file mode 100644 index 0000000000000..289ffe67f4b79 --- /dev/null +++ b/tasks/coverage/misc/fail/declare-before-export-modifier.ts @@ -0,0 +1 @@ +declare export function foo() {} diff --git a/tasks/coverage/misc/fail/duplicate-declare-modifier.ts b/tasks/coverage/misc/fail/duplicate-declare-modifier.ts new file mode 100644 index 0000000000000..bf102c0a3d8e0 --- /dev/null +++ b/tasks/coverage/misc/fail/duplicate-declare-modifier.ts @@ -0,0 +1 @@ +declare declare function foo() {} diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 3c6d1aed1029a..ad2dec201d4e0 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: AST Parsed : 51/51 (100.00%) Positive Passed: 51/51 (100.00%) -Negative Passed: 119/119 (100.00%) +Negative Passed: 121/121 (100.00%) × Cannot assign to 'arguments' in strict mode ╭─[misc/fail/arguments-eval.ts:1:10] @@ -50,6 +50,26 @@ Negative Passed: 119/119 (100.00%) 8 │ ╰──── + × TS(1030): 'export' modifier already seen. + ╭─[misc/fail/declare-before-export-modifier.ts:1:9] + 1 │ declare export function foo() {} + · ────── + ╰──── + help: Remove the duplicate modifier. + + × TS(1183): An implementation cannot be declared in ambient contexts. + ╭─[misc/fail/declare-before-export-modifier.ts:1:31] + 1 │ declare export function foo() {} + · ▲ + ╰──── + + × 'export' modifier cannot be used here. + ╭─[misc/fail/declare-before-export-modifier.ts:1:9] + 1 │ declare export function foo() {} + · ────── + ╰──── + help: Allowed modifiers are: declare, async + × Encountered diff marker ╭─[misc/fail/diff-markers.js:10:1] 9 │ function test() { @@ -72,6 +92,19 @@ Negative Passed: 119/119 (100.00%) If you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased. If you have nested conflicts, resolve the outermost conflict first. + × TS(1030): 'declare' modifier already seen. + ╭─[misc/fail/duplicate-declare-modifier.ts:1:9] + 1 │ declare declare function foo() {} + · ─────── + ╰──── + help: Remove the duplicate modifier. + + × TS(1183): An implementation cannot be declared in ambient contexts. + ╭─[misc/fail/duplicate-declare-modifier.ts:1:32] + 1 │ declare declare function foo() {} + · ▲ + ╰──── + × TS(1030): 'export' modifier already seen. ╭─[misc/fail/duplicate-export-modifier.ts:1:8] 1 │ export export function foo() {