UNPKG

knip

Version:

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

74 lines (73 loc) 2.3 kB
import type { Fix, Fixes } from './exports.ts'; import type { IssueSymbol, SymbolType } from './issues.ts'; export type Identifier = string; type FilePath = string; type NamespaceOrAlias = string; type Reference = string; type References = Set<Reference>; type Tags = Set<string>; export interface Position { pos: number; line: number; col: number; } export type IdToFileMap = Map<Identifier, Set<FilePath>>; export type IdToNsToFileMap = Map<Identifier, Map<NamespaceOrAlias, Set<FilePath>>>; export type ImportMaps = { refs: References; import: IdToFileMap; importAs: IdToNsToFileMap; importNs: IdToFileMap; reExport: IdToFileMap; reExportNs: IdToFileMap; reExportAs: IdToNsToFileMap; }; export type ImportMap = Map<FilePath, ImportMaps>; export interface Import extends Position { readonly specifier: string; readonly filePath: string | undefined; readonly identifier: string | undefined; readonly isTypeOnly: boolean; } export interface ExternalRef { readonly specifier: string; readonly identifier: string | undefined; } export interface Export extends Position { readonly identifier: Identifier; readonly type: SymbolType; readonly members: ExportMember[]; readonly jsDocTags: Tags; hasRefsInFile: boolean; referencedIn: Set<string> | undefined; readonly fixes: Fixes; readonly isReExport: boolean; } export interface ExportMember extends Position { readonly identifier: Identifier; readonly type: SymbolType; readonly fix: Fix; readonly jsDocTags: Tags; readonly flags: number; hasRefsInFile: boolean; } export type ExportMap = Map<Identifier, Export>; export type Imports = Set<Import>; export type FileNode = { imports: { readonly internal: ImportMap; readonly external: Set<Import>; readonly externalRefs: Set<ExternalRef>; unresolved: Set<Import>; readonly programFiles: Set<FilePath>; readonly entryFiles: Set<FilePath>; readonly imports: Imports; }; exports: ExportMap; duplicates: Iterable<Array<IssueSymbol>>; scripts: Set<string>; importedBy: undefined | ImportMaps; internalImportCache: undefined | ImportMap; }; export type ModuleGraph = Map<FilePath, FileNode>; export {};