[ts] Make ImportDeclaration always have importKind (#12170)

This commit is contained in:
Sosuke Suzuki 2020-10-30 04:07:10 +09:00 committed by GitHub
parent ff6c3792bb
commit 963537d5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View File

@ -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") */

View File

@ -0,0 +1 @@
import "foo";

View File

@ -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": []
}
}