astx
Version:
super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring
48 lines (47 loc) • 1.66 kB
TypeScript
import { TransformResult } from '../Astx';
import { Backend } from '../backend/Backend';
import { Match } from '../find';
import { Location } from '../types';
import { SourceLocation } from '../util/CodeFrameError';
export declare type IpcPath = (string | number)[];
export declare type IpcNode = {
location: Location;
};
export declare type IpcMatch = {
type: 'node' | 'nodes';
path: IpcPath;
node: IpcNode;
paths: IpcPath[];
nodes: IpcNode[];
pathCaptures?: Record<string, IpcPath>;
captures?: Record<string, IpcNode>;
arrayPathCaptures?: Record<string, IpcPath[]>;
arrayCaptures?: Record<string, IpcNode[]>;
stringCaptures?: Record<string, string>;
};
export declare function makeIpcMatch(backend: Backend, { type, path, node, paths, nodes, pathCaptures, captures, arrayPathCaptures, arrayCaptures, stringCaptures, }: Match): IpcMatch;
export declare type IpcCodeFrameError = {
name: 'CodeFrameError';
message: string;
stack?: string;
filename?: string;
source?: string;
path?: IpcPath;
loc?: SourceLocation;
};
export declare type IpcOtherError = {
name: 'Error';
message: string;
stack?: string;
};
export declare type IpcError = IpcCodeFrameError | IpcOtherError;
export declare type IpcTransformResult = {
file: string;
source?: string;
transformed?: string;
reports?: any[];
error?: IpcError;
matches?: readonly IpcMatch[];
};
export declare function makeIpcTransformResult({ file, source, transformed, reports, error, matches, backend, }: TransformResult): IpcTransformResult;
export declare function invertIpcError(error: IpcError): Error;