1 |
|
2 |
|
3 |
|
4 | import type * as ts from 'typescript';
|
5 | export interface PluginConfig {
|
6 | [x: string]: any;
|
7 | |
8 |
|
9 |
|
10 | name?: string;
|
11 | |
12 |
|
13 |
|
14 | transform?: string;
|
15 | |
16 |
|
17 |
|
18 | resolvePathAliases?: boolean;
|
19 | |
20 |
|
21 |
|
22 | tsConfig?: string;
|
23 | |
24 |
|
25 |
|
26 | import?: string;
|
27 | |
28 |
|
29 |
|
30 | isEsm?: boolean;
|
31 | |
32 |
|
33 |
|
34 | type?: 'ls' | 'program' | 'config' | 'checker' | 'raw' | 'compilerOptions';
|
35 | |
36 |
|
37 |
|
38 | after?: boolean;
|
39 | |
40 |
|
41 |
|
42 | afterDeclarations?: boolean;
|
43 | |
44 |
|
45 |
|
46 |
|
47 | transformProgram?: boolean;
|
48 | }
|
49 | export type TransformerList = Required<ts.CustomTransformers>;
|
50 | export type TransformerPlugin = TransformerBasePlugin | TsTransformerFactory;
|
51 | export type TsTransformerFactory = ts.TransformerFactory<ts.SourceFile>;
|
52 | export type PluginFactory = LSPattern | ProgramPattern | ConfigPattern | CompilerOptionsPattern | TypeCheckerPattern | RawPattern;
|
53 | export interface TransformerBasePlugin {
|
54 | before?: ts.TransformerFactory<ts.SourceFile> | ts.TransformerFactory<ts.SourceFile>[];
|
55 | after?: ts.TransformerFactory<ts.SourceFile> | ts.TransformerFactory<ts.SourceFile>[];
|
56 | afterDeclarations?: ts.TransformerFactory<ts.SourceFile | ts.Bundle> | ts.TransformerFactory<ts.SourceFile | ts.Bundle>[];
|
57 | }
|
58 | export type DiagnosticMap = WeakMap<ts.Program, ts.Diagnostic[]>;
|
59 | export type TransformerExtras = {
|
60 | |
61 |
|
62 |
|
63 | ts: typeof ts;
|
64 | |
65 |
|
66 |
|
67 | library: string;
|
68 | addDiagnostic: (diag: ts.Diagnostic) => number;
|
69 | removeDiagnostic: (index: number) => void;
|
70 | diagnostics: readonly ts.Diagnostic[];
|
71 | };
|
72 | export type ProgramTransformerExtras = {
|
73 | |
74 |
|
75 |
|
76 | ts: typeof ts;
|
77 | };
|
78 | export type ProgramTransformer = (program: ts.Program, host: ts.CompilerHost | undefined, config: PluginConfig, extras: ProgramTransformerExtras) => ts.Program;
|
79 | export type LSPattern = (ls: ts.LanguageService, config: {}) => TransformerPlugin;
|
80 | export type CompilerOptionsPattern = (compilerOpts: ts.CompilerOptions, config: {}) => TransformerPlugin;
|
81 | export type ConfigPattern = (config: {}) => TransformerPlugin;
|
82 | export type TypeCheckerPattern = (checker: ts.TypeChecker, config: {}) => TransformerPlugin;
|
83 | export type ProgramPattern = (program: ts.Program, config: {}, extras: TransformerExtras) => TransformerPlugin;
|
84 | export type RawPattern = (context: ts.TransformationContext, program: ts.Program, config: {}) => ts.Transformer<ts.SourceFile>;
|
85 | export interface PluginPackageConfig {
|
86 | tscOptions?: {
|
87 | |
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | parseAllJsDoc?: boolean;
|
94 | };
|
95 | }
|