forked from rollup/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
81 lines (68 loc) 路 2.65 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { FilterPattern } from '@rollup/pluginutils';
import { Plugin } from 'rollup';
import { CompilerOptions, CustomTransformers, Program, TypeChecker } from 'typescript';
export interface RollupTypescriptPluginOptions {
/**
* If using incremental this is the folder where the cached
* files will be created and kept for Typescript incremental
* compilation.
*/
cacheDir?: string;
/**
* Determine which files are transpiled by Typescript (all `.ts` and
* `.tsx` files by default).
*/
include?: FilterPattern;
/**
* Determine which files are ignored by Typescript
*/
exclude?: FilterPattern;
/**
* When set to false, ignores any options specified in the config file.
* If set to a string that corresponds to a file path, the specified file
* will be used as config file.
*/
tsconfig?: string | false;
/**
* Overrides TypeScript used for transpilation
*/
typescript?: typeof import('typescript');
/**
* Overrides the injected TypeScript helpers with a custom version.
*/
tslib?: Promise<string> | string;
/**
* TypeScript custom transformers
*/
transformers?: CustomTransformerFactories;
}
type ElementType<T extends Array<any> | undefined> = T extends (infer U)[] ? U : never;
export type TransformerStage = keyof CustomTransformers;
type StagedTransformerFactory<T extends TransformerStage> = ElementType<CustomTransformers[T]>;
type TransformerFactory<T extends TransformerStage> =
| StagedTransformerFactory<T>
| ProgramTransformerFactory<T>
| TypeCheckerTransformerFactory<T>;
export type CustomTransformerFactories = {
[stage in TransformerStage]?: Array<TransformerFactory<stage>>;
};
interface ProgramTransformerFactory<T extends TransformerStage> {
type: 'program';
factory(program: Program): StagedTransformerFactory<T>;
}
interface TypeCheckerTransformerFactory<T extends TransformerStage> {
type: 'typeChecker';
factory(typeChecker: TypeChecker): StagedTransformerFactory<T>;
}
/** Properties of `CompilerOptions` that are normally enums */
export type EnumCompilerOptions = 'module' | 'moduleResolution' | 'newLine' | 'jsx' | 'target';
/** JSON representation of Typescript compiler options */
export type JsonCompilerOptions = Omit<CompilerOptions, EnumCompilerOptions> &
Record<EnumCompilerOptions, string>;
/** Compiler options set by the plugin user. */
export type PartialCompilerOptions = Partial<CompilerOptions> | Partial<JsonCompilerOptions>;
export type RollupTypescriptOptions = RollupTypescriptPluginOptions & PartialCompilerOptions;
/**
* Seamless integration between Rollup and Typescript.
*/
export default function typescript(options?: RollupTypescriptOptions): Plugin;