7d5e922788719c85489a172556428b2109aee5b5.svn-base
5.65 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import { BaseError } from 'make-error';
import * as _ts from 'typescript';
/**
* Registered `ts-node` instance information.
*/
export declare const REGISTER_INSTANCE: unique symbol;
/**
* Expose `REGISTER_INSTANCE` information on node.js `process`.
*/
declare global {
namespace NodeJS {
interface Process {
[REGISTER_INSTANCE]?: Register;
}
}
}
/**
* Common TypeScript interfaces between versions.
*/
export interface TSCommon {
version: typeof _ts.version;
sys: typeof _ts.sys;
ScriptSnapshot: typeof _ts.ScriptSnapshot;
displayPartsToString: typeof _ts.displayPartsToString;
createLanguageService: typeof _ts.createLanguageService;
getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
transpileModule: typeof _ts.transpileModule;
ModuleKind: typeof _ts.ModuleKind;
ScriptTarget: typeof _ts.ScriptTarget;
findConfigFile: typeof _ts.findConfigFile;
readConfigFile: typeof _ts.readConfigFile;
parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
formatDiagnostics: typeof _ts.formatDiagnostics;
formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
}
/**
* Export the current version.
*/
export declare const VERSION: any;
/**
* Options for creating a new TypeScript compiler instance.
*/
export interface CreateOptions {
/**
* Specify working directory for config resolution.
*
* @default process.cwd()
*/
dir?: string;
/**
* Emit output files into `.ts-node` directory.
*
* @default false
*/
emit?: boolean;
/**
* Scope compiler to files within `cwd`.
*
* @default false
*/
scope?: boolean;
/**
* Use pretty diagnostic formatter.
*
* @default false
*/
pretty?: boolean;
/**
* Use TypeScript's faster `transpileModule`.
*
* @default false
*/
transpileOnly?: boolean;
/**
* **DEPRECATED** Specify type-check is enabled (e.g. `transpileOnly == false`).
*
* @default true
*/
typeCheck?: boolean;
/**
* Use TypeScript's compiler host API.
*
* @default false
*/
compilerHost?: boolean;
/**
* Logs TypeScript errors to stderr instead of throwing exceptions.
*
* @default false
*/
logError?: boolean;
/**
* Load files from `tsconfig.json` on startup.
*
* @default false
*/
files?: boolean;
/**
* Specify a custom TypeScript compiler.
*
* @default "typescript"
*/
compiler?: string;
/**
* Override the path patterns to skip compilation.
*
* @default /node_modules/
* @docsDefault "/node_modules/"
*/
ignore?: string[];
/**
* Path to TypeScript JSON project file.
*/
project?: string;
/**
* Skip project config resolution and loading.
*
* @default false
*/
skipProject?: boolean;
/**
* Skip ignore check.
*
* @default false
*/
skipIgnore?: boolean;
/**
* JSON object to merge with compiler options.
*
* @allOf [{"$ref": "https://schemastore.azurewebsites.net/schemas/json/tsconfig.json#definitions/compilerOptionsDefinition/properties/compilerOptions"}]
*/
compilerOptions?: object;
/**
* Ignore TypeScript warnings by diagnostic code.
*/
ignoreDiagnostics?: Array<number | string>;
readFile?: (path: string) => string | undefined;
fileExists?: (path: string) => boolean;
transformers?: _ts.CustomTransformers | ((p: _ts.Program) => _ts.CustomTransformers);
}
/**
* Options for registering a TypeScript compiler instance globally.
*/
export interface RegisterOptions extends CreateOptions {
/**
* Re-order file extensions so that TypeScript imports are preferred.
*
* @default false
*/
preferTsExts?: boolean;
}
/**
* Must be an interface to support `typescript-json-schema`.
*/
export interface TsConfigOptions extends Omit<RegisterOptions, 'transformers' | 'readFile' | 'fileExists' | 'skipProject' | 'project' | 'dir'> {
}
/**
* Information retrieved from type info check.
*/
export interface TypeInfo {
name: string;
comment: string;
}
/**
* Default register options, including values specified via environment
* variables.
*/
export declare const DEFAULTS: RegisterOptions;
/**
* Split a string array of values.
*/
export declare function split(value: string | undefined): string[] | undefined;
/**
* Parse a string as JSON.
*/
export declare function parse(value: string | undefined): object | undefined;
/**
* Replace backslashes with forward slashes.
*/
export declare function normalizeSlashes(value: string): string;
/**
* TypeScript diagnostics error.
*/
export declare class TSError extends BaseError {
diagnosticText: string;
diagnosticCodes: number[];
name: string;
constructor(diagnosticText: string, diagnosticCodes: number[]);
}
/**
* Return type for registering `ts-node`.
*/
export interface Register {
ts: TSCommon;
config: _ts.ParsedCommandLine;
options: RegisterOptions;
enabled(enabled?: boolean): boolean;
ignored(fileName: string): boolean;
compile(code: string, fileName: string, lineOffset?: number): string;
getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
}
/**
* Register TypeScript compiler instance onto node.js
*/
export declare function register(opts?: RegisterOptions): Register;
/**
* Create TypeScript compiler instance.
*/
export declare function create(rawOptions?: CreateOptions): Register;