fix(javascript): exclude erased imports from runtime bindings (#6994)
This commit is contained in:
1 parent
0402012a95
commit
be2811e414
4 files changed
+53
-27
No files matched your search
@@ -80,6 +80,8 @@ import {
|
||||
} from "./javascriptSemanticAmbientWrites.js";
|
||||
import {
|
||||
hasUncertainTypeOnlyModuleSideEffect,
|
||||
isTypeOnlyImportDeclaration,
|
||||
isTypeOnlyImportSpecifier,
|
||||
semanticImportEqualsSpecifier,
|
||||
} from "./javascriptModuleDeclaration.js";
|
||||
import {
|
||||
@@ -2038,7 +2040,10 @@ const bindImports = (
|
||||
scope: JavaScriptSemanticScopeState,
|
||||
state: JavaScriptSemanticAnalysisState,
|
||||
): void => {
|
||||
if (isTypeOnlyImportDeclaration(node)) return;
|
||||
for (const specifier of node.specifiers) {
|
||||
if (t.isImportSpecifier(specifier) && isTypeOnlyImportSpecifier(specifier))
|
||||
continue;
|
||||
const importedPath = t.isImportDefaultSpecifier(specifier)
|
||||
? ["default"]
|
||||
: t.isImportNamespaceSpecifier(specifier)
|
||||
@@ -2053,12 +2058,7 @@ const bindImports = (
|
||||
definitionNode: specifier.local,
|
||||
initializer: null,
|
||||
directOrigin: { specifier: node.source.value, importedPath },
|
||||
runtimeImport:
|
||||
node.importKind !== "type" &&
|
||||
node.importKind !== "typeof" &&
|
||||
(!t.isImportSpecifier(specifier) ||
|
||||
(specifier.importKind !== "type" &&
|
||||
specifier.importKind !== "typeof")),
|
||||
runtimeImport: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user