UNPKG

knip

Version:

Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects

54 lines (53 loc) 2.5 kB
import type { ParseResult } from 'oxc-parser'; import { CacheConsultant } from './CacheConsultant.ts'; import type { AsyncCompilers, SyncCompilers } from './compilers/types.ts'; import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile, PluginVisitorContext, PluginVisitorObject } from './types/config.ts'; import type { FileNode, ModuleGraph } from './types/module-graph.ts'; import type { Paths } from './types/project.ts'; import { SourceFileManager } from './typescript/SourceFileManager.ts'; import type { MainOptions } from './util/create-options.ts'; import type { ToSourceFilePath } from './util/to-source-path.ts'; export declare class ProjectPrincipal { entryPaths: Set<string>; projectPaths: Set<string>; programPaths: Set<string>; skipExportsAnalysis: Set<string>; pluginCtx: PluginVisitorContext; pluginVisitorObjects: PluginVisitorObject[]; private _visitor; syncCompilers: SyncCompilers; asyncCompilers: AsyncCompilers; private paths; private rootDirs; private extensions; cache: CacheConsultant<FileNode>; toSourceFilePath: ToSourceFilePath; fileManager: SourceFileManager; private resolveModule; resolvedFiles: Set<string>; deletedFiles: Set<string>; constructor(options: MainOptions, toSourceFilePath: ToSourceFilePath); addCompilers(compilers: [SyncCompilers, AsyncCompilers]): void; addPaths(paths: Paths, basePath: string): void; addRootDirs(rootDirs: string[]): void; init(): void; readFile(filePath: string): string; private hasAcceptedExtension; addEntryPath(filePath: string, options?: { skipExportsAnalysis: boolean; }): void; addEntryPaths(filePaths: Set<string> | string[], options?: { skipExportsAnalysis: boolean; }): void; addProgramPath(filePath: string): void; addProjectPath(filePath: string): void; removeProjectPath(filePath: string): void; runAsyncCompilers(): Promise<void>; walkAndAnalyze(analyzeFile: (filePath: string, parseResult: ParseResult | undefined, sourceText: string) => Iterable<string> | undefined): void; getUsedResolvedFiles(): string[]; private resolveSpecifier; getUnreferencedFiles(): string[]; analyzeSourceFile(filePath: string, options: GetImportsAndExportsOptions, ignoreExportsUsedInFile: IgnoreExportsUsedInFile, parseResult?: ParseResult, sourceText?: string): FileNode; invalidateFile(filePath: string): void; reconcileCache(graph: ModuleGraph): void; }