Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/parser): Fix parsing of
import type from from
(#8309)
**Related issue:** - Closes #8308.
- Loading branch information
1 parent
af8c1d3
commit 00b8839
Showing
8 changed files
with
191 additions
and
35 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
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
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 @@ | ||
import type from from "foo"; |
51 changes: 51 additions & 0 deletions
51
crates/swc_ecma_parser/tests/typescript/issue-8308/1/input.ts.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,51 @@ | ||
{ | ||
"type": "Module", | ||
"span": { | ||
"start": 1, | ||
"end": 29, | ||
"ctxt": 0 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ImportDeclaration", | ||
"span": { | ||
"start": 1, | ||
"end": 29, | ||
"ctxt": 0 | ||
}, | ||
"specifiers": [ | ||
{ | ||
"type": "ImportDefaultSpecifier", | ||
"span": { | ||
"start": 13, | ||
"end": 17, | ||
"ctxt": 0 | ||
}, | ||
"local": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 13, | ||
"end": 17, | ||
"ctxt": 0 | ||
}, | ||
"value": "from", | ||
"optional": false | ||
} | ||
} | ||
], | ||
"source": { | ||
"type": "StringLiteral", | ||
"span": { | ||
"start": 23, | ||
"end": 28, | ||
"ctxt": 0 | ||
}, | ||
"value": "foo", | ||
"raw": "\"foo\"" | ||
}, | ||
"typeOnly": true, | ||
"with": null | ||
} | ||
], | ||
"interpreter": null | ||
} |
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 @@ | ||
import type from = require("foo"); |
49 changes: 49 additions & 0 deletions
49
crates/swc_ecma_parser/tests/typescript/issue-8308/2/input.ts.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,49 @@ | ||
{ | ||
"type": "Module", | ||
"span": { | ||
"start": 1, | ||
"end": 35, | ||
"ctxt": 0 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "TsImportEqualsDeclaration", | ||
"span": { | ||
"start": 1, | ||
"end": 35, | ||
"ctxt": 0 | ||
}, | ||
"isExport": false, | ||
"isTypeOnly": true, | ||
"id": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 13, | ||
"end": 17, | ||
"ctxt": 0 | ||
}, | ||
"value": "from", | ||
"optional": false | ||
}, | ||
"moduleRef": { | ||
"type": "TsExternalModuleReference", | ||
"span": { | ||
"start": 20, | ||
"end": 34, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "StringLiteral", | ||
"span": { | ||
"start": 28, | ||
"end": 33, | ||
"ctxt": 0 | ||
}, | ||
"value": "foo", | ||
"raw": "\"foo\"" | ||
} | ||
} | ||
} | ||
], | ||
"interpreter": null | ||
} |
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 @@ | ||
import type async = require("foo"); |
49 changes: 49 additions & 0 deletions
49
crates/swc_ecma_parser/tests/typescript/issue-8308/3/input.ts.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,49 @@ | ||
{ | ||
"type": "Module", | ||
"span": { | ||
"start": 1, | ||
"end": 36, | ||
"ctxt": 0 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "TsImportEqualsDeclaration", | ||
"span": { | ||
"start": 1, | ||
"end": 36, | ||
"ctxt": 0 | ||
}, | ||
"isExport": false, | ||
"isTypeOnly": true, | ||
"id": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 13, | ||
"end": 18, | ||
"ctxt": 0 | ||
}, | ||
"value": "async", | ||
"optional": false | ||
}, | ||
"moduleRef": { | ||
"type": "TsExternalModuleReference", | ||
"span": { | ||
"start": 21, | ||
"end": 35, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "StringLiteral", | ||
"span": { | ||
"start": 29, | ||
"end": 34, | ||
"ctxt": 0 | ||
}, | ||
"value": "foo", | ||
"raw": "\"foo\"" | ||
} | ||
} | ||
} | ||
], | ||
"interpreter": null | ||
} |