import { JavaScriptVisitor } from "./visitor"; import { J } from "../java"; import { JS } from "./tree"; /** * @param visitor The visitor to add the import removal to * @param module The module name (e.g., 'fs', 'react') to remove imports from * @param member Optionally, the specific member to remove from the import. * If not specified, removes all unused imports from the module. * Special values: * - 'default': Removes the default import from the module if unused, * regardless of its local name (e.g., `import React from 'react'`) * - '*': Removes the namespace import if unused (e.g., `import * as fs from 'fs'`) * * @example * // Remove a specific named import if unused * maybeRemoveImport(visitor, 'fs', 'readFile'); * * @example * // Remove the default import from 'react' if unused (regardless of local name) * maybeRemoveImport(visitor, 'react', 'default'); * * @example * // Remove all unused imports from 'react' module * maybeRemoveImport(visitor, 'react'); * * @example * // Remove namespace import if unused * maybeRemoveImport(visitor, 'fs', '*'); */ export declare function maybeRemoveImport(visitor: JavaScriptVisitor, module: string, member?: string): void; export declare class RemoveImport

extends JavaScriptVisitor

{ readonly module: string; readonly member?: string | undefined; /** * @param module The module name (e.g., 'fs', 'react') to remove imports from * @param member Optionally, the specific member to remove from the import. * If not specified, removes all unused imports from the module. * Special values: * - 'default': Removes the default import from the module if unused, * regardless of its local name * - '*': Removes the namespace import if unused */ constructor(module: string, member?: string | undefined); /** * Generic helper to filter elements from a RightPadded array while preserving formatting. * When removing elements, the prefix from the first removed element is applied to the * first remaining element to maintain proper spacing. Also preserves trailing space * from the last element if it's removed. */ private filterElementsWithPrefixPreservation; /** * Helper to update an import clause by removing specific bindings */ private updateImportClause; visitJsCompilationUnit(compilationUnit: JS.CompilationUnit, p: P): Promise; private processImport; /** * Process TypeScript import-equals-require syntax: import util = require("util"); * This is represented as a JS.Import with an initializer containing the require() call. */ private processImportEqualsRequire; /** * Check if a node is a require() method invocation */ private isRequireCall; /** * Check if the module name matches the target module */ private matchesTargetModule; /** * Check if an identifier should be removed based on usage */ private shouldRemoveIdentifier; private processNamedImports; private processRequireFromVarDecls; /** * Get the module name from a require() call */ private getModuleNameFromRequire; private processObjectBindingPattern; private getImportName; private getImportAlias; private getBindingElementName; private shouldRemoveImport; private isTargetModule; /** * Helper to traverse parameters from various node types */ private traverseParameters; /** * Helper to traverse statements from various node types */ private traverseStatements; /** * Helper to check for type expressions and collect type usage */ private checkTypeExpression; private collectUsedIdentifiers; private collectTypeUsage; } //# sourceMappingURL=remove-import.d.ts.map