Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/oxc_parser/src/modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,7 @@ 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));
}
self.check_for_duplicate_modifiers(flags, &modifier);
flags.set(modifier_flags, true);
Expand Down
1 change: 1 addition & 0 deletions tasks/coverage/misc/fail/declare-before-export-modifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare export function foo() {}
1 change: 1 addition & 0 deletions tasks/coverage/misc/fail/duplicate-declare-modifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare declare function foo() {}
2 changes: 2 additions & 0 deletions tasks/coverage/misc/fail/duplicate-export-modifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export export function foo() {
}
51 changes: 50 additions & 1 deletion tasks/coverage/snapshots/parser_misc.snap
Original file line number Diff line number Diff line change
@@ -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: 121/121 (100.00%)

× Cannot assign to 'arguments' in strict mode
╭─[misc/fail/arguments-eval.ts:1:10]
Expand Down Expand Up @@ -50,6 +50,26 @@ Negative Passed: 118/118 (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() {
Expand All @@ -72,6 +92,35 @@ 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): '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() {
· ──────
2 │ }
╰────
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";
Expand Down
51 changes: 34 additions & 17 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6082,13 +6082,14 @@ 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]
Expand All @@ -6099,13 +6100,14 @@ 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/compiler/exportAlreadySeen.ts:3:12]
2 │ export export var x = 1;
3 │ export export function f() { }
· ──────
4 │
╰────
help: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:3:12]
Expand All @@ -6116,21 +6118,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va
╰────
help: Allowed modifiers are: declare, async

× 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.
× 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: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:6:16]
Expand All @@ -6141,13 +6145,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va
╰────
help: Allowed modifiers are: declare, abstract

× TS(1029): 'export' modifier must precede 'declare' modifier.
× 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: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:7:16]
Expand All @@ -6167,13 +6172,14 @@ 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/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.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:12:12]
Expand All @@ -6184,13 +6190,14 @@ 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/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.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:13:12]
Expand All @@ -6201,21 +6208,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va
╰────
help: Allowed modifiers are: declare, async

× 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.
× 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: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:16:16]
Expand All @@ -6226,13 +6235,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va
╰────
help: Allowed modifiers are: declare, abstract

× TS(1029): 'export' modifier must precede 'declare' modifier.
× 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: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/exportAlreadySeen.ts:17:16]
Expand Down Expand Up @@ -6600,13 +6610,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]
Expand Down Expand Up @@ -6753,21 +6764,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]
Expand Down Expand Up @@ -9663,13 +9676,14 @@ 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/privacyImportParseErrors.ts:326:9]
325 │
326 │ declare export module "anotherParseError2" {
· ──────
327 │ namespace m2 {
╰────
help: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/compiler/privacyImportParseErrors.ts:326:9]
Expand Down Expand Up @@ -19591,13 +19605,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]
Expand Down Expand Up @@ -22077,12 +22092,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 │ }
╰────
help: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration6.ts:1:8]
Expand Down Expand Up @@ -22592,12 +22608,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() {
╰────
help: Remove the duplicate modifier.

× 'export' modifier cannot be used here.
╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts:1:8]
Expand Down
Loading