1 | import { FilterPattern } from '@rollup/pluginutils';
|
2 | import { Plugin } from 'rollup';
|
3 | import { CompilerOptions, CustomTransformers } from 'typescript';
|
4 |
|
5 | export interface RollupTypescriptPluginOptions {
|
6 | |
7 |
|
8 |
|
9 |
|
10 | include?: FilterPattern;
|
11 | |
12 |
|
13 |
|
14 | exclude?: FilterPattern;
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | tsconfig?: string | false;
|
21 | |
22 |
|
23 |
|
24 | typescript?: typeof import('typescript');
|
25 | |
26 |
|
27 |
|
28 | tslib?: Promise<string> | string;
|
29 | |
30 |
|
31 |
|
32 | transformers?: CustomTransformerFactories;
|
33 | }
|
34 |
|
35 | type ElementType<T extends Array<any>> = T extends (infer U)[] ? U : never;
|
36 |
|
37 | export type TransformerStage = keyof CustomTransformers;
|
38 | type StagedTransformerFactory<T extends TransformerStage> = ElementType<CustomTransformers[T]>;
|
39 | type TransformerFactory<T extends TransformerStage> =
|
40 | | StagedTransformerFactory<T>
|
41 | | ProgramTransformerFactory<T>
|
42 | | TypeCheckerTransformerFactory<T>;
|
43 |
|
44 | export type CustomTransformerFactories = {
|
45 | [stage in TransformerStage]?: Array<TransformerFactory<stage>>;
|
46 | };
|
47 |
|
48 | interface ProgramTransformerFactory<T extends TransformerStage> {
|
49 | type: 'program';
|
50 |
|
51 | factory(program: Program): StagedTransformerFactory<T>;
|
52 | }
|
53 |
|
54 | interface TypeCheckerTransformerFactory<T extends TransformerStage> {
|
55 | type: 'typeChecker';
|
56 |
|
57 | factory(typeChecker: TypeChecker): StagedTransformerFactory<T>;
|
58 | }
|
59 |
|
60 |
|
61 | export type EnumCompilerOptions = 'module' | 'moduleResolution' | 'newLine' | 'jsx' | 'target';
|
62 |
|
63 |
|
64 | export type JsonCompilerOptions = Omit<CompilerOptions, EnumCompilerOptions> &
|
65 | Record<EnumCompilerOptions, string>;
|
66 |
|
67 |
|
68 | export type PartialCompilerOptions = Partial<CompilerOptions> | Partial<JsonCompilerOptions>;
|
69 |
|
70 | export type RollupTypescriptOptions = RollupTypescriptPluginOptions & PartialCompilerOptions;
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | export default function typescript(options?: RollupTypescriptOptions): Plugin;
|