Skip to content

Commit

Permalink
other: #192 🔹 restore getImportedName (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubugeeei authored Dec 29, 2023
1 parent 4706599 commit 38bcb6e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/compiler-core/src/babelUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Identifier, Node, Function } from "@babel/types";
import {
Identifier,
ImportDefaultSpecifier,
ImportNamespaceSpecifier,
ImportSpecifier,
Function,
Node,
} from "@babel/types";

import { walk } from "estree-walker";

Expand Down Expand Up @@ -106,6 +113,17 @@ export const isFunctionType = (node: Node): node is Function => {
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
};

export function getImportedName(
specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
) {
if (specifier.type === "ImportSpecifier")
return specifier.imported.type === "Identifier"
? specifier.imported.name
: specifier.imported.value;
else if (specifier.type === "ImportNamespaceSpecifier") return "*";
return "default";
}

export function isReferencedIdentifier(
id: Identifier,
parent: Node | null,
Expand Down

0 comments on commit 38bcb6e

Please sign in to comment.