UNPKG

typescript-transform-paths

Version:

Transforms module resolution paths using TypeScript path mapping and/or custom paths

47 lines (46 loc) 2 kB
import type { Minimatch } from "minimatch"; import type { PluginConfig } from "ts-patch"; import type ts from "typescript"; import type { CompilerOptions, EmitHost, Pattern, SourceFile } from "typescript"; export type ImportOrExportDeclaration = ts.ImportDeclaration | ts.ExportDeclaration; export type ImportOrExportClause = ts.ImportDeclaration["importClause"] | ts.ExportDeclaration["exportClause"]; export interface TsTransformPathsConfig extends PluginConfig { readonly useRootDirs?: boolean; readonly exclude?: string[]; } export interface TsTransformPathsContext { /** TS Instance passed from ts-patch / ttypescript */ readonly tsInstance: typeof ts; readonly tsVersionMajor: number; readonly tsVersionMinor: number; readonly tsFactory?: ts.NodeFactory; readonly runMode: RunMode; readonly tsNodeState?: TsNodeState; readonly program?: ts.Program; readonly config: TsTransformPathsConfig; readonly compilerOptions: CompilerOptions; readonly elisionMap: Map<ts.SourceFile, Map<ImportOrExportDeclaration, ImportOrExportDeclaration>>; readonly transformationContext: ts.TransformationContext; readonly rootDirs?: string[]; readonly excludeMatchers: Minimatch[] | undefined; readonly outputFileNamesCache: Map<SourceFile, string>; readonly pathsPatterns: readonly (string | Pattern)[] | undefined; readonly emitHost: EmitHost; } export interface VisitorContext extends TsTransformPathsContext { readonly factory: ts.NodeFactory; readonly sourceFile: ts.SourceFile; readonly isDeclarationFile: boolean; readonly originalSourceFile: ts.SourceFile; getVisitor(): (node: ts.Node) => ts.VisitResult<ts.Node>; } export declare const RunMode: { Manual: string; Program: string; }; export type RunMode = (typeof RunMode)[keyof typeof RunMode]; export declare const TsNodeState: { Full: number; Stripped: number; }; export type TsNodeState = (typeof TsNodeState)[keyof typeof TsNodeState];