diff --git a/crates/swc_ecma_parser/src/parser/stmt/module_item.rs b/crates/swc_ecma_parser/src/parser/stmt/module_item.rs index b27cea78e72..312e3d0938d 100644 --- a/crates/swc_ecma_parser/src/parser/stmt/module_item.rs +++ b/crates/swc_ecma_parser/src/parser/stmt/module_item.rs @@ -529,12 +529,12 @@ impl<'a, I: Tokens> Parser { && is!(self, "const") && peeked_is!(self, "enum") { - let start = cur_pos!(self); + let enum_start = cur_pos!(self); assert_and_bump!(self, "const"); let _ = cur!(self, true); assert_and_bump!(self, "enum"); return self - .parse_ts_enum_decl(start, /* is_const */ true) + .parse_ts_enum_decl(enum_start, /* is_const */ true) .map(Decl::from) .map(|decl| { ModuleDecl::ExportDecl(ExportDecl { diff --git a/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts b/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts new file mode 100644 index 00000000000..e51a1a46686 --- /dev/null +++ b/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts @@ -0,0 +1 @@ +export const enum A {} diff --git a/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts.spans b/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts.spans new file mode 100644 index 00000000000..02c40b06f11 --- /dev/null +++ b/crates/swc_ecma_parser/tests/span/ts/decl/export-const-enum.ts.spans @@ -0,0 +1,42 @@ +warning: Module + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:1 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: ModuleItem + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:1 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: ModuleDecl + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:1 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: ExportDecl + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:1 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: Decl + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:8 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^ + +warning: TsEnumDecl + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:8 + | +1 | export const enum A {} + | ^^^^^^^^^^^^^^^ + +warning: Ident + --> $DIR/tests/span/ts/decl/export-const-enum.ts:1:19 + | +1 | export const enum A {} + | ^ + diff --git a/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target5.json b/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target5.json index 5060ba8a622..d1dfcef1961 100644 --- a/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target5.json +++ b/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target5.json @@ -58,7 +58,7 @@ { "type": "ExportDeclaration", "span": { - "start": 103, + "start": 96, "end": 131, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target5.json b/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target5.json index 5060ba8a622..d1dfcef1961 100644 --- a/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target5.json +++ b/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target5.json @@ -58,7 +58,7 @@ { "type": "ExportDeclaration", "span": { - "start": 103, + "start": 96, "end": 131, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json index dd5093a1cad..10ab7fa711b 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json @@ -259,7 +259,7 @@ { "type": "ExportDeclaration", "span": { - "start": 174, + "start": 167, "end": 202, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json index 120b659e632..586b57ab8f5 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json @@ -259,7 +259,7 @@ { "type": "ExportDeclaration", "span": { - "start": 179, + "start": 172, "end": 207, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json index bba0c97296d..765f5ec2b83 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json @@ -259,7 +259,7 @@ { "type": "ExportDeclaration", "span": { - "start": 163, + "start": 156, "end": 191, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json b/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json index 93930f0b6c1..b0719b0e7ca 100644 --- a/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json +++ b/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json @@ -104,7 +104,7 @@ { "type": "ExportDeclaration", "span": { - "start": 149, + "start": 142, "end": 174, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json index df474b4d584..bf3bfa3e851 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json @@ -643,7 +643,7 @@ { "type": "ExportDeclaration", "span": { - "start": 605, + "start": 598, "end": 645, "ctxt": 0 }, @@ -996,7 +996,7 @@ { "type": "ExportDeclaration", "span": { - "start": 759, + "start": 752, "end": 861, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json b/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json index e8c8f6e9229..ca0e44a4615 100644 --- a/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json +++ b/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json @@ -148,7 +148,7 @@ { "type": "ExportDeclaration", "span": { - "start": 209, + "start": 202, "end": 226, "ctxt": 0 }, diff --git a/crates/swc_ecma_parser/tests/typescript/enum/export-const/input.ts.json b/crates/swc_ecma_parser/tests/typescript/enum/export-const/input.ts.json index 5cfcc2208d2..360983b0ca6 100644 --- a/crates/swc_ecma_parser/tests/typescript/enum/export-const/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/enum/export-const/input.ts.json @@ -9,7 +9,7 @@ { "type": "ExportDeclaration", "span": { - "start": 7, + "start": 0, "end": 22, "ctxt": 0 },