mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 14:16:12 +03:00
fix(es/parser): Fix the span of an export declaration containing a const enum (#3701)
This commit is contained in:
parent
7e1f3202d5
commit
4318a2e73b
@ -529,12 +529,12 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
&& 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 {
|
||||
|
@ -0,0 +1 @@
|
||||
export const enum A {}
|
@ -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 {}
|
||||
| ^
|
||||
|
@ -58,7 +58,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 103,
|
||||
"start": 96,
|
||||
"end": 131,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -58,7 +58,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 103,
|
||||
"start": 96,
|
||||
"end": 131,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -259,7 +259,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 174,
|
||||
"start": 167,
|
||||
"end": 202,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -259,7 +259,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 179,
|
||||
"start": 172,
|
||||
"end": 207,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -259,7 +259,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 163,
|
||||
"start": 156,
|
||||
"end": 191,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -104,7 +104,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 149,
|
||||
"start": 142,
|
||||
"end": 174,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -148,7 +148,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 209,
|
||||
"start": 202,
|
||||
"end": 226,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
@ -9,7 +9,7 @@
|
||||
{
|
||||
"type": "ExportDeclaration",
|
||||
"span": {
|
||||
"start": 7,
|
||||
"start": 0,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user