Quick fix for typescript import crash. (#6879)

This commit is contained in:
Logan Smyth
2017-11-22 13:27:31 -08:00
committed by GitHub
parent ccd7c25174
commit 80b4b7120b

View File

@@ -44,7 +44,14 @@ export default function() {
for (const specifier of path.node.specifiers) {
const binding = path.scope.getBinding(specifier.local.name);
if (isImportTypeOnly(binding, state.programPath)) {
// The binding may not exist if the import node was explicitly
// injected by another plugin. Currently core does not do a good job
// of keeping scope bindings synchronized with the AST. For now we
// just bail if there is no binding, since chances are good that if
// the import statement was injected then it wasn't a typescript type
// import anyway.
if (binding && isImportTypeOnly(binding, state.programPath)) {
importsToRemove.push(binding.path);
} else {
allElided = false;