Skip to content

Commit

Permalink
[ts] Make ImportDeclaration always have importKind (#12170)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Oct 29, 2020
1 parent ff6c379 commit 963537d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -2007,11 +2007,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
) {
node.importKind = "type";
this.next();
} else {
node.importKind = "value";
}
}

if (!node.importKind) {
node.importKind = "value";
}

const importNode = super.parseImport(node);
/*:: invariant(importNode.type !== "TSImportEqualsDeclaration") */

Expand Down
@@ -0,0 +1 @@
import "foo";
@@ -0,0 +1,28 @@
{
"type": "File",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"program": {
"type": "Program",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ImportDeclaration",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"importKind": "value",
"specifiers": [],
"source": {
"type": "StringLiteral",
"start":7,"end":12,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":12}},
"extra": {
"rawValue": "foo",
"raw": "\"foo\""
},
"value": "foo"
}
}
],
"directives": []
}
}

0 comments on commit 963537d

Please sign in to comment.