ts-jest 29.0.1 → 29.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ts-jest-digest +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/cli/config/init.d.ts +5 -0
- package/dist/cli/config/init.js +62 -20
- package/dist/cli/config/migrate.js +50 -10
- package/dist/cli/help.js +7 -1
- package/dist/cli/helpers/presets.js +12 -5
- package/dist/cli/index.js +9 -5
- package/dist/config/paths-to-module-name-mapper.js +6 -2
- package/dist/constants.js +5 -0
- package/dist/legacy/compiler/compiler-utils.d.ts +6 -0
- package/dist/legacy/compiler/compiler-utils.js +10 -0
- package/dist/legacy/compiler/ts-compiler.d.ts +6 -0
- package/dist/legacy/compiler/ts-compiler.js +76 -7
- package/dist/legacy/compiler/ts-jest-compiler.js +2 -1
- package/dist/legacy/config/config-set.d.ts +7 -0
- package/dist/legacy/config/config-set.js +91 -12
- package/dist/legacy/ts-jest-transformer.d.ts +13 -0
- package/dist/legacy/ts-jest-transformer.js +57 -10
- package/dist/raw-compiler-options.d.ts +297 -0
- package/dist/transformers/hoist-jest.d.ts +4 -0
- package/dist/transformers/hoist-jest.js +24 -0
- package/dist/types.d.ts +101 -6
- package/dist/utils/backports.js +13 -4
- package/dist/utils/get-package-version.js +3 -0
- package/dist/utils/importer.js +31 -4
- package/dist/utils/json.js +9 -0
- package/dist/utils/jsonable-value.js +2 -1
- package/dist/utils/logger.js +1 -0
- package/dist/utils/memoize.js +20 -1
- package/dist/utils/messages.js +5 -0
- package/dist/utils/normalize-slashes.js +3 -0
- package/dist/utils/sha1.js +10 -0
- package/dist/utils/ts-error.js +12 -2
- package/dist/utils/version-checkers.js +9 -5
- package/package.json +4 -4
|
@@ -86,14 +86,21 @@ var sha1_1 = require("../utils/sha1");
|
|
|
86
86
|
var version_checkers_1 = require("../utils/version-checkers");
|
|
87
87
|
var compiler_1 = require("./compiler");
|
|
88
88
|
var config_set_1 = require("./config/config-set");
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
89
92
|
exports.CACHE_KEY_EL_SEPARATOR = '\x00';
|
|
90
|
-
var TsJestTransformer = (function () {
|
|
93
|
+
var TsJestTransformer = /** @class */ (function () {
|
|
91
94
|
function TsJestTransformer(tsJestConfig) {
|
|
92
95
|
this.tsJestConfig = tsJestConfig;
|
|
93
96
|
this._depGraphs = new Map();
|
|
94
97
|
this._watchMode = false;
|
|
95
98
|
this._logger = utils_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
|
96
99
|
version_checkers_1.VersionCheckers.jest.warn();
|
|
100
|
+
/**
|
|
101
|
+
* For some unknown reasons, `this` is undefined in `getCacheKey` and `process`
|
|
102
|
+
* when running Jest in ESM mode
|
|
103
|
+
*/
|
|
97
104
|
this.getCacheKey = this.getCacheKey.bind(this);
|
|
98
105
|
this.getCacheKeyAsync = this.getCacheKeyAsync.bind(this);
|
|
99
106
|
this.process = this.process.bind(this);
|
|
@@ -115,9 +122,13 @@ var TsJestTransformer = (function () {
|
|
|
115
122
|
configSet = ccs.configSet;
|
|
116
123
|
}
|
|
117
124
|
else {
|
|
125
|
+
// try to look-it up by stringified version
|
|
118
126
|
var serializedJestCfg_1 = (0, utils_1.stringify)(config);
|
|
119
127
|
var serializedCcs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.serialized === serializedJestCfg_1; });
|
|
120
128
|
if (serializedCcs) {
|
|
129
|
+
// update the object so that we can find it later
|
|
130
|
+
// this happens because jest first calls getCacheKey with stringified version of
|
|
131
|
+
// the config, and then it calls the transformer with the proper object
|
|
121
132
|
serializedCcs.jestConfig.value = config;
|
|
122
133
|
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
|
123
134
|
this._compiler = serializedCcs.compiler;
|
|
@@ -127,15 +138,18 @@ var TsJestTransformer = (function () {
|
|
|
127
138
|
configSet = serializedCcs.configSet;
|
|
128
139
|
}
|
|
129
140
|
else {
|
|
141
|
+
// create the new record in the index
|
|
130
142
|
this._logger.info('no matching config-set found, creating a new one');
|
|
131
143
|
if ((_a = config.globals) === null || _a === void 0 ? void 0 : _a['ts-jest']) {
|
|
132
|
-
this._logger.warn("Define `ts-jest` config under `globals` is deprecated. Please do\ntransform: {\n <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],\n},");
|
|
144
|
+
this._logger.warn("Define `ts-jest` config under `globals` is deprecated. Please do\ntransform: {\n <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],\n}," /* Deprecations.GlobalsTsJestConfigOption */);
|
|
133
145
|
}
|
|
134
146
|
var migratedConfig = this.tsJestConfig
|
|
135
147
|
? __assign(__assign({}, config), { globals: __assign(__assign({}, ((_b = config.globals) !== null && _b !== void 0 ? _b : Object.create(null))), { 'ts-jest': this.tsJestConfig }) }) : config;
|
|
136
148
|
configSet = this._createConfigSet(migratedConfig);
|
|
137
149
|
var jest_1 = __assign({}, migratedConfig);
|
|
138
|
-
|
|
150
|
+
// we need to remove some stuff from jest config
|
|
151
|
+
// this which does not depend on config
|
|
152
|
+
jest_1.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
139
153
|
this._transformCfgStr = "".concat(new utils_1.JsonableValue(jest_1).serialized).concat(configSet.cacheSuffix);
|
|
140
154
|
this._createCompiler(configSet, cacheFS);
|
|
141
155
|
this._getFsCachedResolvedModules(configSet);
|
|
@@ -153,12 +167,16 @@ var TsJestTransformer = (function () {
|
|
|
153
167
|
}
|
|
154
168
|
return configSet;
|
|
155
169
|
};
|
|
170
|
+
// eslint-disable-next-line class-methods-use-this
|
|
156
171
|
TsJestTransformer.prototype._createConfigSet = function (config) {
|
|
157
172
|
return new config_set_1.ConfigSet(config);
|
|
158
173
|
};
|
|
159
174
|
TsJestTransformer.prototype._createCompiler = function (configSet, cacheFS) {
|
|
160
175
|
this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
|
|
161
176
|
};
|
|
177
|
+
/**
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
162
180
|
TsJestTransformer.prototype.process = function (sourceText, sourcePath, transformOptions) {
|
|
163
181
|
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
|
|
164
182
|
var configs = this._configsFor(transformOptions);
|
|
@@ -169,6 +187,7 @@ var TsJestTransformer = (function () {
|
|
|
169
187
|
};
|
|
170
188
|
if (babelJest) {
|
|
171
189
|
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
|
190
|
+
// do not instrument here, jest will do it anyway afterwards
|
|
172
191
|
result = babelJest.process(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }));
|
|
173
192
|
}
|
|
174
193
|
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
|
@@ -179,7 +198,7 @@ var TsJestTransformer = (function () {
|
|
|
179
198
|
var _this = this;
|
|
180
199
|
return __generator(this, function (_a) {
|
|
181
200
|
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
|
|
182
|
-
return [2
|
|
201
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
183
202
|
var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
|
|
184
203
|
var _a;
|
|
185
204
|
return __generator(this, function (_b) {
|
|
@@ -195,16 +214,17 @@ var TsJestTransformer = (function () {
|
|
|
195
214
|
if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
|
|
196
215
|
reject(configs.createTsError(processWithTsResult.diagnostics));
|
|
197
216
|
}
|
|
198
|
-
if (!babelJest) return [3
|
|
217
|
+
if (!babelJest) return [3 /*break*/, 2];
|
|
199
218
|
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
|
200
|
-
return [4
|
|
219
|
+
return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
|
|
201
220
|
case 1:
|
|
221
|
+
// do not instrument here, jest will do it anyway afterwards
|
|
202
222
|
result = _b.sent();
|
|
203
223
|
_b.label = 2;
|
|
204
224
|
case 2:
|
|
205
225
|
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
|
206
226
|
resolve(result);
|
|
207
|
-
return [2];
|
|
227
|
+
return [2 /*return*/];
|
|
208
228
|
}
|
|
209
229
|
});
|
|
210
230
|
}); })];
|
|
@@ -220,22 +240,26 @@ var TsJestTransformer = (function () {
|
|
|
220
240
|
var isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
|
|
221
241
|
var isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
|
|
222
242
|
if (shouldStringifyContent) {
|
|
243
|
+
// handles here what we should simply stringify
|
|
223
244
|
result = {
|
|
224
245
|
code: "module.exports=".concat((0, utils_1.stringify)(sourceText)),
|
|
225
246
|
};
|
|
226
247
|
}
|
|
227
248
|
else if (isDefinitionFile) {
|
|
249
|
+
// do not try to compile declaration files
|
|
228
250
|
result = {
|
|
229
251
|
code: '',
|
|
230
252
|
};
|
|
231
253
|
}
|
|
232
254
|
else if (!configs.parsedTsConfig.options.allowJs && isJsFile) {
|
|
233
|
-
|
|
255
|
+
// we've got a '.js' but the compiler option `allowJs` is not set or set to false
|
|
256
|
+
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)("Got a `.js` file to compile while `allowJs` option is not set to `true` (file: {{path}}). To fix this:\n - if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)\n - if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore" /* Errors.GotJsFileButAllowJsFalse */, { path: sourcePath }));
|
|
234
257
|
result = {
|
|
235
258
|
code: sourceText,
|
|
236
259
|
};
|
|
237
260
|
}
|
|
238
261
|
else if (isJsFile || isTsFile) {
|
|
262
|
+
// transpile TS code (source maps are included)
|
|
239
263
|
result = this._compiler.getCompiledOutput(sourceText, sourcePath, {
|
|
240
264
|
depGraphs: this._depGraphs,
|
|
241
265
|
supportsStaticESM: transformOptions.supportsStaticESM,
|
|
@@ -243,7 +267,10 @@ var TsJestTransformer = (function () {
|
|
|
243
267
|
});
|
|
244
268
|
}
|
|
245
269
|
else {
|
|
246
|
-
|
|
270
|
+
// we should not get called for files with other extension than js[x], ts[x] and d.ts,
|
|
271
|
+
// TypeScript will bail if we try to compile, and if it was to call babel, users can
|
|
272
|
+
// define the transform value with `babel-jest` for this extension instead
|
|
273
|
+
var message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." /* Errors.GotUnknownFileTypeWithBabel */ : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore." /* Errors.GotUnknownFileTypeWithoutBabel */;
|
|
247
274
|
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)(message, { path: sourcePath }));
|
|
248
275
|
result = {
|
|
249
276
|
code: sourceText,
|
|
@@ -254,10 +281,12 @@ var TsJestTransformer = (function () {
|
|
|
254
281
|
TsJestTransformer.prototype.runTsJestHook = function (sourcePath, sourceText, transformOptions, compiledOutput) {
|
|
255
282
|
var hooksFile = process.env.TS_JEST_HOOKS;
|
|
256
283
|
var hooks;
|
|
284
|
+
/* istanbul ignore next (cover by e2e) */
|
|
257
285
|
if (hooksFile) {
|
|
258
286
|
hooksFile = path_1.default.resolve(this._configsFor(transformOptions).cwd, hooksFile);
|
|
259
287
|
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
|
260
288
|
}
|
|
289
|
+
// This is not supposed to be a public API but we keep it as some people use it
|
|
261
290
|
if (hooks === null || hooks === void 0 ? void 0 : hooks.afterProcess) {
|
|
262
291
|
this._logger.debug({ fileName: sourcePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
|
|
263
292
|
var newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
|
|
@@ -267,10 +296,18 @@ var TsJestTransformer = (function () {
|
|
|
267
296
|
}
|
|
268
297
|
return compiledOutput;
|
|
269
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* Jest uses this to cache the compiled version of a file
|
|
301
|
+
*
|
|
302
|
+
* @see https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
|
|
303
|
+
*
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
270
306
|
TsJestTransformer.prototype.getCacheKey = function (fileContent, filePath, transformOptions) {
|
|
271
307
|
var _a;
|
|
272
308
|
var configs = this._configsFor(transformOptions);
|
|
273
309
|
this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'computing cache key for', filePath);
|
|
310
|
+
// we do not instrument, ensure it is false all the time
|
|
274
311
|
var _b = transformOptions.instrument, instrument = _b === void 0 ? false : _b;
|
|
275
312
|
var constructingCacheKeyElements = [
|
|
276
313
|
this._transformCfgStr,
|
|
@@ -287,6 +324,7 @@ var TsJestTransformer = (function () {
|
|
|
287
324
|
var resolvedModuleNames = void 0;
|
|
288
325
|
if (((_a = this._depGraphs.get(filePath)) === null || _a === void 0 ? void 0 : _a.fileContent) === fileContent) {
|
|
289
326
|
this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
290
328
|
resolvedModuleNames = this._depGraphs
|
|
291
329
|
.get(filePath)
|
|
292
330
|
.resolvedModuleNames.filter(function (moduleName) { return (0, fs_1.existsSync)(moduleName); });
|
|
@@ -309,13 +347,17 @@ var TsJestTransformer = (function () {
|
|
|
309
347
|
TsJestTransformer.prototype.getCacheKeyAsync = function (sourceText, sourcePath, transformOptions) {
|
|
310
348
|
return __awaiter(this, void 0, void 0, function () {
|
|
311
349
|
return __generator(this, function (_a) {
|
|
312
|
-
return [2
|
|
350
|
+
return [2 /*return*/, Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions))];
|
|
313
351
|
});
|
|
314
352
|
});
|
|
315
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
|
|
356
|
+
*/
|
|
316
357
|
TsJestTransformer.prototype._getFsCachedResolvedModules = function (configSet) {
|
|
317
358
|
var cacheDir = configSet.tsCacheDir;
|
|
318
359
|
if (!configSet.isolatedModules && cacheDir) {
|
|
360
|
+
// Make sure the cache directory exists before continuing.
|
|
319
361
|
(0, fs_1.mkdirSync)(cacheDir, { recursive: true });
|
|
320
362
|
this._tsResolvedModulesCachePath = path_1.default.join(cacheDir, (0, sha1_1.sha1)('ts-jest-resolved-modules', exports.CACHE_KEY_EL_SEPARATOR));
|
|
321
363
|
try {
|
|
@@ -325,6 +367,11 @@ var TsJestTransformer = (function () {
|
|
|
325
367
|
catch (e) { }
|
|
326
368
|
}
|
|
327
369
|
};
|
|
370
|
+
/**
|
|
371
|
+
* cache ConfigSet between test runs
|
|
372
|
+
*
|
|
373
|
+
* @internal
|
|
374
|
+
*/
|
|
328
375
|
TsJestTransformer._cachedConfigSets = [];
|
|
329
376
|
return TsJestTransformer;
|
|
330
377
|
}());
|
|
@@ -1,106 +1,403 @@
|
|
|
1
1
|
export interface RawCompilerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* No longer supported. In early versions, manually set the text encoding for reading files.
|
|
4
|
+
*/
|
|
2
5
|
charset?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Enable constraints that allow a TypeScript project to be used with project references.
|
|
8
|
+
*/
|
|
3
9
|
composite?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Generate .d.ts files from TypeScript and JavaScript files in your project.
|
|
12
|
+
*/
|
|
4
13
|
declaration?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the output directory for generated declaration files.
|
|
16
|
+
*/
|
|
5
17
|
declarationDir?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Output compiler performance information after building.
|
|
20
|
+
*/
|
|
6
21
|
diagnostics?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Reduce the number of projects loaded automatically by TypeScript.
|
|
24
|
+
*/
|
|
7
25
|
disableReferencedProjectLoad?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Enforces using indexed accessors for keys declared using an indexed type
|
|
28
|
+
*/
|
|
8
29
|
noPropertyAccessFromIndexSignature?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
|
32
|
+
*/
|
|
9
33
|
emitBOM?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Only output d.ts files and not JavaScript files.
|
|
36
|
+
*/
|
|
10
37
|
emitDeclarationOnly?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Save .tsbuildinfo files to allow for incremental compilation of projects.
|
|
40
|
+
*/
|
|
11
41
|
incremental?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify the folder for .tsbuildinfo incremental compilation files.
|
|
44
|
+
*/
|
|
12
45
|
tsBuildInfoFile?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Include sourcemap files inside the emitted JavaScript.
|
|
48
|
+
*/
|
|
13
49
|
inlineSourceMap?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Include source code in the sourcemaps inside the emitted JavaScript.
|
|
52
|
+
*/
|
|
14
53
|
inlineSources?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Specify what JSX code is generated.
|
|
56
|
+
*/
|
|
15
57
|
jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
|
|
58
|
+
/**
|
|
59
|
+
* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit.
|
|
60
|
+
*/
|
|
16
61
|
reactNamespace?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'
|
|
64
|
+
*/
|
|
17
65
|
jsxFactory?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
|
68
|
+
*/
|
|
18
69
|
jsxFragmentFactory?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`
|
|
72
|
+
*/
|
|
19
73
|
jsxImportSource?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Print all of the files read during the compilation.
|
|
76
|
+
*/
|
|
20
77
|
listFiles?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Specify the location where debugger should locate map files instead of generated locations.
|
|
80
|
+
*/
|
|
21
81
|
mapRoot?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Specify what module code is generated.
|
|
84
|
+
*/
|
|
22
85
|
module?: ('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None') | string;
|
|
86
|
+
/**
|
|
87
|
+
* Specify how TypeScript looks up a file from a given module specifier.
|
|
88
|
+
*/
|
|
23
89
|
moduleResolution?: ('Classic' | 'Node') | string;
|
|
90
|
+
/**
|
|
91
|
+
* Set the newline character for emitting files.
|
|
92
|
+
*/
|
|
24
93
|
newLine?: ('crlf' | 'lf') | string;
|
|
94
|
+
/**
|
|
95
|
+
* Disable emitting file from a compilation.
|
|
96
|
+
*/
|
|
25
97
|
noEmit?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Disable generating custom helper functions like `__extends` in compiled output.
|
|
100
|
+
*/
|
|
26
101
|
noEmitHelpers?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Disable emitting files if any type checking errors are reported.
|
|
104
|
+
*/
|
|
27
105
|
noEmitOnError?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Enable error reporting for expressions and declarations with an implied `any` type..
|
|
108
|
+
*/
|
|
28
109
|
noImplicitAny?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Enable error reporting when `this` is given the type `any`.
|
|
112
|
+
*/
|
|
29
113
|
noImplicitThis?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Enable error reporting when a local variables aren't read.
|
|
116
|
+
*/
|
|
30
117
|
noUnusedLocals?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Raise an error when a function parameter isn't read
|
|
120
|
+
*/
|
|
31
121
|
noUnusedParameters?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Disable including any library files, including the default lib.d.ts.
|
|
124
|
+
*/
|
|
32
125
|
noLib?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.
|
|
128
|
+
*/
|
|
33
129
|
noResolve?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Disable strict checking of generic signatures in function types.
|
|
132
|
+
*/
|
|
34
133
|
noStrictGenericChecks?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Skip type checking .d.ts files that are included with TypeScript.
|
|
136
|
+
*/
|
|
35
137
|
skipDefaultLibCheck?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Skip type checking all .d.ts files.
|
|
140
|
+
*/
|
|
36
141
|
skipLibCheck?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.
|
|
144
|
+
*/
|
|
37
145
|
outFile?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Specify an output folder for all emitted files.
|
|
148
|
+
*/
|
|
38
149
|
outDir?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Disable erasing `const enum` declarations in generated code.
|
|
152
|
+
*/
|
|
39
153
|
preserveConstEnums?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Disable resolving symlinks to their realpath. This correlates to the same flag in node.
|
|
156
|
+
*/
|
|
40
157
|
preserveSymlinks?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Disable wiping the console in watch mode
|
|
160
|
+
*/
|
|
41
161
|
preserveWatchOutput?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Enable color and formatting in output to make compiler errors easier to read
|
|
164
|
+
*/
|
|
42
165
|
pretty?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Disable emitting comments.
|
|
168
|
+
*/
|
|
43
169
|
removeComments?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Specify the root folder within your source files.
|
|
172
|
+
*/
|
|
44
173
|
rootDir?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Ensure that each file can be safely transpiled without relying on other imports.
|
|
176
|
+
*/
|
|
45
177
|
isolatedModules?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Create source map files for emitted JavaScript files.
|
|
180
|
+
*/
|
|
46
181
|
sourceMap?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Specify the root path for debuggers to find the reference source code.
|
|
184
|
+
*/
|
|
47
185
|
sourceRoot?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Disable reporting of excess property errors during the creation of object literals.
|
|
188
|
+
*/
|
|
48
189
|
suppressExcessPropertyErrors?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Suppress `noImplicitAny` errors when indexing objects that lack index signatures.
|
|
192
|
+
*/
|
|
49
193
|
suppressImplicitAnyIndexErrors?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
|
|
196
|
+
*/
|
|
50
197
|
target?: ('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ESNext') | string;
|
|
198
|
+
/**
|
|
199
|
+
* Watch input files.
|
|
200
|
+
*/
|
|
51
201
|
watch?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Specify what approach the watcher should use if the system runs out of native file watchers.
|
|
204
|
+
*/
|
|
52
205
|
fallbackPolling?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling';
|
|
206
|
+
/**
|
|
207
|
+
* Specify how directories are watched on systems that lack recursive file-watching functionality.
|
|
208
|
+
*/
|
|
53
209
|
watchDirectory?: 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling';
|
|
210
|
+
/**
|
|
211
|
+
* Specify how the TypeScript watch mode works.
|
|
212
|
+
*/
|
|
54
213
|
watchFile?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory';
|
|
214
|
+
/**
|
|
215
|
+
* Enable experimental support for TC39 stage 2 draft decorators.
|
|
216
|
+
*/
|
|
55
217
|
experimentalDecorators?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Emit design-type metadata for decorated declarations in source files.
|
|
220
|
+
*/
|
|
56
221
|
emitDecoratorMetadata?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Disable error reporting for unused labels.
|
|
224
|
+
*/
|
|
57
225
|
allowUnusedLabels?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Enable error reporting for codepaths that do not explicitly return in a function.
|
|
228
|
+
*/
|
|
58
229
|
noImplicitReturns?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Add `undefined` to a type when accessed using an index.
|
|
232
|
+
*/
|
|
59
233
|
noUncheckedIndexedAccess?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Enable error reporting for fallthrough cases in switch statements.
|
|
236
|
+
*/
|
|
60
237
|
noFallthroughCasesInSwitch?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Disable error reporting for unreachable code.
|
|
240
|
+
*/
|
|
61
241
|
allowUnreachableCode?: boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Ensure that casing is correct in imports.
|
|
244
|
+
*/
|
|
62
245
|
forceConsistentCasingInFileNames?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Emit a v8 CPU profile of the compiler run for debugging.
|
|
248
|
+
*/
|
|
63
249
|
generateCpuProfile?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Specify the base directory to resolve non-relative module names.
|
|
252
|
+
*/
|
|
64
253
|
baseUrl?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Specify a set of entries that re-map imports to additional lookup locations.
|
|
256
|
+
*/
|
|
65
257
|
paths?: {
|
|
66
258
|
[k: string]: string[];
|
|
67
259
|
};
|
|
260
|
+
/**
|
|
261
|
+
* Specify a list of language service plugins to include.
|
|
262
|
+
*/
|
|
68
263
|
plugins?: Array<{
|
|
264
|
+
/**
|
|
265
|
+
* Plugin name.
|
|
266
|
+
*/
|
|
69
267
|
name?: string;
|
|
70
268
|
[k: string]: unknown;
|
|
71
269
|
}>;
|
|
270
|
+
/**
|
|
271
|
+
* Allow multiple folders to be treated as one when resolving modules.
|
|
272
|
+
*/
|
|
72
273
|
rootDirs?: string[];
|
|
274
|
+
/**
|
|
275
|
+
* Specify multiple folders that act like `./node_modules/@types`.
|
|
276
|
+
*/
|
|
73
277
|
typeRoots?: string[];
|
|
278
|
+
/**
|
|
279
|
+
* Specify type package names to be included without being referenced in a source file.
|
|
280
|
+
*/
|
|
74
281
|
types?: string[];
|
|
282
|
+
/**
|
|
283
|
+
* Log paths used during the `moduleResolution` process.
|
|
284
|
+
*/
|
|
75
285
|
traceResolution?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
|
|
288
|
+
*/
|
|
76
289
|
allowJs?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Disable truncating types in error messages.
|
|
292
|
+
*/
|
|
77
293
|
noErrorTruncation?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Allow 'import x from y' when a module doesn't have a default export.
|
|
296
|
+
*/
|
|
78
297
|
allowSyntheticDefaultImports?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Disable adding 'use strict' directives in emitted JavaScript files.
|
|
300
|
+
*/
|
|
79
301
|
noImplicitUseStrict?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Print the names of emitted files after a compilation.
|
|
304
|
+
*/
|
|
80
305
|
listEmittedFiles?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
|
|
308
|
+
*/
|
|
81
309
|
disableSizeLimit?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Specify a set of bundled library declaration files that describe the target runtime environment.
|
|
312
|
+
*/
|
|
82
313
|
lib?: Array<('ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.ImportScripts') | string>;
|
|
314
|
+
/**
|
|
315
|
+
* When type checking, take into account `null` and `undefined`.
|
|
316
|
+
*/
|
|
83
317
|
strictNullChecks?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`.
|
|
320
|
+
*/
|
|
84
321
|
maxNodeModuleJsDepth?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Allow importing helper functions from tslib once per project, instead of including them per-file.
|
|
324
|
+
*/
|
|
85
325
|
importHelpers?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Specify emit/checking behavior for imports that are only used for types.
|
|
328
|
+
*/
|
|
86
329
|
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
|
|
330
|
+
/**
|
|
331
|
+
* Ensure 'use strict' is always emitted.
|
|
332
|
+
*/
|
|
87
333
|
alwaysStrict?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Enable all strict type checking options.
|
|
336
|
+
*/
|
|
88
337
|
strict?: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Check that the arguments for `bind`, `call`, and `apply` methods match the original function.
|
|
340
|
+
*/
|
|
89
341
|
strictBindCallApply?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Emit more compliant, but verbose and less performant JavaScript for iteration.
|
|
344
|
+
*/
|
|
90
345
|
downlevelIteration?: boolean;
|
|
346
|
+
/**
|
|
347
|
+
* Enable error reporting in type-checked JavaScript files.
|
|
348
|
+
*/
|
|
91
349
|
checkJs?: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* When assigning functions, check to ensure parameters and the return values are subtype-compatible.
|
|
352
|
+
*/
|
|
92
353
|
strictFunctionTypes?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Check for class properties that are declared but not set in the constructor.
|
|
356
|
+
*/
|
|
93
357
|
strictPropertyInitialization?: boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
|
|
360
|
+
*/
|
|
94
361
|
esModuleInterop?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Allow accessing UMD globals from modules.
|
|
364
|
+
*/
|
|
95
365
|
allowUmdGlobalAccess?: boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Make keyof only return strings instead of string, numbers or symbols. Legacy option.
|
|
368
|
+
*/
|
|
96
369
|
keyofStringsOnly?: boolean;
|
|
370
|
+
/**
|
|
371
|
+
* Emit ECMAScript-standard-compliant class fields.
|
|
372
|
+
*/
|
|
97
373
|
useDefineForClassFields?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Create sourcemaps for d.ts files.
|
|
376
|
+
*/
|
|
98
377
|
declarationMap?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Enable importing .json files
|
|
380
|
+
*/
|
|
99
381
|
resolveJsonModule?: boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it.
|
|
384
|
+
*/
|
|
100
385
|
assumeChangesOnlyAffectDirectDependencies?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Output more detailed compiler performance information after building.
|
|
388
|
+
*/
|
|
101
389
|
extendedDiagnostics?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Print names of files that are part of the compilation and then stop processing.
|
|
392
|
+
*/
|
|
102
393
|
listFilesOnly?: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Disable preferring source files instead of declaration files when referencing composite projects
|
|
396
|
+
*/
|
|
103
397
|
disableSourceOfProjectReferenceRedirect?: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Opt a project out of multi-project reference checking when editing.
|
|
400
|
+
*/
|
|
104
401
|
disableSolutionSearching?: boolean;
|
|
105
402
|
[k: string]: unknown;
|
|
106
403
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type _ts from 'typescript';
|
|
2
2
|
import type { TsCompilerInstance } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Remember to increase the version whenever transformer's content is changed. This is to inform Jest to not reuse
|
|
5
|
+
* the previous cache which contains old transformer's content
|
|
6
|
+
*/
|
|
3
7
|
export declare const version = 4;
|
|
4
8
|
export declare const name = "hoist-jest";
|
|
5
9
|
export declare function factory({ configSet }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|