Skip to content

Commit

Permalink
chore: use getImportEqualsDeclarations in removeImportEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Feb 29, 2024
1 parent 6a91b13 commit d41647f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/transforms/v2-to-v3/modules/removeImportEquals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Collection, JSCodeshift } from "jscodeshift";
import { getImportEqualsDeclarations } from "./importEqualsModule";
import { removeDeclaration } from "./removeDeclaration";

export interface RemoveImportEqualsOptions {
Expand All @@ -11,14 +12,9 @@ export const removeImportEquals = (
source: Collection<unknown>,
{ localName, sourceValue }: RemoveImportEqualsOptions
) => {
const importEqualsDeclaration = source.find(j.TSImportEqualsDeclaration, {
type: "TSImportEqualsDeclaration",
id: { name: localName },
moduleReference: {
type: "TSExternalModuleReference",
expression: { type: "StringLiteral", value: sourceValue },
},
});
const importEqualsDeclaration = getImportEqualsDeclarations(j, source, sourceValue).filter(
(importEqualsDeclaration) => importEqualsDeclaration.value.id.name === localName
);
if (importEqualsDeclaration.length) {
removeDeclaration(j, source, importEqualsDeclaration.get());
}
Expand Down

0 comments on commit d41647f

Please sign in to comment.