1 | import * as ts from 'typescript';
|
2 | export interface PluginConfig {
|
3 | |
4 |
|
5 |
|
6 | name?: string;
|
7 | |
8 |
|
9 |
|
10 | transform?: string;
|
11 | |
12 |
|
13 |
|
14 | import?: string;
|
15 | |
16 |
|
17 |
|
18 | type?: 'ls' | 'program' | 'config' | 'checker' | 'raw' | 'compilerOptions';
|
19 | |
20 |
|
21 |
|
22 | after?: boolean;
|
23 | |
24 |
|
25 |
|
26 | afterDeclarations?: boolean;
|
27 | }
|
28 | export interface TransformerBasePlugin {
|
29 | before?: ts.TransformerFactory<ts.SourceFile>;
|
30 | after?: ts.TransformerFactory<ts.SourceFile>;
|
31 | afterDeclarations?: ts.TransformerFactory<ts.SourceFile | ts.Bundle>;
|
32 | }
|
33 | export declare type TransformerList = Required<ts.CustomTransformers>;
|
34 | export declare type TransformerPlugin = TransformerBasePlugin | ts.TransformerFactory<ts.SourceFile>;
|
35 | export declare type LSPattern = (ls: ts.LanguageService, config: {}) => TransformerPlugin;
|
36 | export declare type ProgramPattern = (program: ts.Program, config: {}, helpers?: {
|
37 | ts: typeof ts;
|
38 | addDiagnostic: (diag: ts.Diagnostic) => void;
|
39 | }) => TransformerPlugin;
|
40 | export declare type CompilerOptionsPattern = (compilerOpts: ts.CompilerOptions, config: {}) => TransformerPlugin;
|
41 | export declare type ConfigPattern = (config: {}) => TransformerPlugin;
|
42 | export declare type TypeCheckerPattern = (checker: ts.TypeChecker, config: {}) => TransformerPlugin;
|
43 | export declare type RawPattern = (context: ts.TransformationContext, program: ts.Program, config: {}) => ts.Transformer<ts.SourceFile>;
|
44 | export declare type PluginFactory = LSPattern | ProgramPattern | ConfigPattern | CompilerOptionsPattern | TypeCheckerPattern | RawPattern;
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export declare class PluginCreator {
|
55 | private typescript;
|
56 | private configs;
|
57 | private resolveBaseDir;
|
58 | constructor(typescript: typeof ts, configs: PluginConfig[], resolveBaseDir?: string);
|
59 | mergeTransformers(into: TransformerList, source: ts.CustomTransformers | TransformerBasePlugin): this;
|
60 | createTransformers(params: {
|
61 | program: ts.Program;
|
62 | } | {
|
63 | ls: ts.LanguageService;
|
64 | }, customTransformers?: ts.CustomTransformers): Required<ts.CustomTransformers>;
|
65 | private resolveFactory;
|
66 | private validateConfigs;
|
67 | }
|