Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lost leading comment after named import (#10901)
* create test for 10892 * update expected output * fixed #10892 * add colon to restart build * remove colon as it makes tests fail
- Loading branch information
1 parent
416ce35
commit f651f22
Showing
4 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/babel-parser/test/fixtures/comments/regression/10892/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { foo } from "bar" | ||
|
||
/** | ||
* lost comment | ||
*/ | ||
export default { | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/comments/regression/10892/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"sourceType": "module" | ||
} |
206 changes: 206 additions & 0 deletions
206
packages/babel-parser/test/fixtures/comments/regression/10892/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 69, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 7, | ||
"column": 1 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 69, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 7, | ||
"column": 1 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ImportDeclaration", | ||
"start": 0, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
}, | ||
"specifiers": [ | ||
{ | ||
"type": "ImportSpecifier", | ||
"start": 9, | ||
"end": 12, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 12 | ||
} | ||
}, | ||
"imported": { | ||
"type": "Identifier", | ||
"start": 9, | ||
"end": 12, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 12 | ||
}, | ||
"identifierName": "foo" | ||
}, | ||
"name": "foo" | ||
}, | ||
"local": { | ||
"type": "Identifier", | ||
"start": 9, | ||
"end": 12, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 12 | ||
}, | ||
"identifierName": "foo" | ||
}, | ||
"name": "foo" | ||
} | ||
} | ||
], | ||
"source": { | ||
"type": "StringLiteral", | ||
"start": 20, | ||
"end": 25, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 20 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 25 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": "bar", | ||
"raw": "\"bar\"" | ||
}, | ||
"value": "bar" | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": "*\n * lost comment\n ", | ||
"start": 27, | ||
"end": 50, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 3 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start": 51, | ||
"end": 69, | ||
"loc": { | ||
"start": { | ||
"line": 6, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 7, | ||
"column": 1 | ||
} | ||
}, | ||
"declaration": { | ||
"type": "ObjectExpression", | ||
"start": 66, | ||
"end": 69, | ||
"loc": { | ||
"start": { | ||
"line": 6, | ||
"column": 15 | ||
}, | ||
"end": { | ||
"line": 7, | ||
"column": 1 | ||
} | ||
}, | ||
"properties": [] | ||
}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": "*\n * lost comment\n ", | ||
"start": 27, | ||
"end": 50, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 3 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": "*\n * lost comment\n ", | ||
"start": 27, | ||
"end": 50, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 3 | ||
} | ||
} | ||
} | ||
] | ||
} |