fix(es/parser): Fix the span of an export declaration containing a const enum (#3701)

This commit is contained in:
David Sherret 2022-02-23 23:36:05 -05:00 committed by GitHub
parent 7e1f3202d5
commit 4318a2e73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 12 deletions

View File

@ -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 {

View File

@ -0,0 +1 @@
export const enum A {}

View File

@ -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 {}
| ^

View File

@ -58,7 +58,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 103,
"start": 96,
"end": 131,
"ctxt": 0
},

View File

@ -58,7 +58,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 103,
"start": 96,
"end": 131,
"ctxt": 0
},

View File

@ -259,7 +259,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 174,
"start": 167,
"end": 202,
"ctxt": 0
},

View File

@ -259,7 +259,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 179,
"start": 172,
"end": 207,
"ctxt": 0
},

View File

@ -259,7 +259,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 163,
"start": 156,
"end": 191,
"ctxt": 0
},

View File

@ -104,7 +104,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 149,
"start": 142,
"end": 174,
"ctxt": 0
},

View File

@ -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
},

View File

@ -148,7 +148,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 209,
"start": 202,
"end": 226,
"ctxt": 0
},

View File

@ -9,7 +9,7 @@
{
"type": "ExportDeclaration",
"span": {
"start": 7,
"start": 0,
"end": 22,
"ctxt": 0
},