ts-jest
Advanced tools
Comparing version 28.0.4 to 28.0.5
@@ -1,5 +0,5 @@ | ||
import type { TransformedSource } from '@jest/transform'; | ||
import { Logger } from 'bs-logger'; | ||
import type { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript'; | ||
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../../types'; | ||
import { CompiledOutput } from '../../types'; | ||
import type { ConfigSet } from '../config/config-set'; | ||
@@ -18,5 +18,5 @@ export declare class TsCompiler implements TsCompilerInstance { | ||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[]; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput; | ||
protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput; | ||
protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers; | ||
} |
@@ -110,2 +110,3 @@ "use strict"; | ||
TsCompiler.prototype.getCompiledOutput = function (fileContent, fileName, options) { | ||
var e_1, _a; | ||
var moduleKind = this._initialCompilerOptions.module; | ||
@@ -115,2 +116,3 @@ var esModuleInterop = this._initialCompilerOptions.esModuleInterop; | ||
var currentModuleKind = this._compilerOptions.module; | ||
var isEsmMode = this.configSet.useESM && options.supportsStaticESM; | ||
if ((this.configSet.babelJestTransformer || (!this.configSet.babelJestTransformer && options.supportsStaticESM)) && | ||
@@ -135,3 +137,29 @@ this.configSet.useESM) { | ||
var output = this._languageService.getEmitOutput(fileName); | ||
this._doTypeChecking(fileName, options.depGraphs, options.watchMode); | ||
var diagnostics = this.getDiagnostics(fileName); | ||
if (!isEsmMode && diagnostics.length) { | ||
this.configSet.raiseDiagnostics(diagnostics, fileName, this._logger); | ||
if (options.watchMode) { | ||
this._logger.debug({ fileName: fileName }, '_doTypeChecking(): starting watch mode computing diagnostics'); | ||
try { | ||
for (var _b = __values(options.depGraphs.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var entry = _c.value; | ||
var normalizedModuleNames = entry[1].resolvedModuleNames.map(function (moduleName) { return (0, path_1.normalize)(moduleName); }); | ||
var fileToReTypeCheck = entry[0]; | ||
if (normalizedModuleNames.includes(fileName) && this.configSet.shouldReportDiagnostics(fileToReTypeCheck)) { | ||
this._logger.debug({ fileToReTypeCheck: fileToReTypeCheck }, '_doTypeChecking(): computing diagnostics using language service'); | ||
this._updateMemoryCache(this._getFileContentFromCache(fileToReTypeCheck), fileToReTypeCheck); | ||
var importedModulesDiagnostics = __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileToReTypeCheck)), false), __read(this._languageService.getSyntacticDiagnostics(fileToReTypeCheck)), false); | ||
this.configSet.raiseDiagnostics(importedModulesDiagnostics, fileName, this._logger); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
} | ||
if (output.emitSkipped) { | ||
@@ -157,5 +185,7 @@ if (constants_1.TS_TSX_REGEX.test(fileName)) { | ||
code: (0, compiler_utils_1.updateOutput)(outputFiles[1].text, fileName, outputFiles[0].text), | ||
diagnostics: diagnostics, | ||
} | ||
: { | ||
code: (0, compiler_utils_1.updateOutput)(outputFiles[0].text, fileName), | ||
diagnostics: diagnostics, | ||
}; | ||
@@ -198,2 +228,3 @@ } | ||
var _this = this; | ||
var _a; | ||
this._parsedTsConfig.fileNames | ||
@@ -228,3 +259,3 @@ .filter(function (fileName) { return constants_1.TS_TSX_REGEX.test(fileName) && !_this.configSet.isTestFile(fileName); }) | ||
fileExists: (0, lodash_memoize_1.default)(this._ts.sys.fileExists), | ||
readFile: this._cachedReadFile, | ||
readFile: (_a = this._cachedReadFile) !== null && _a !== void 0 ? _a : this._ts.sys.readFile, | ||
readDirectory: (0, lodash_memoize_1.default)(this._ts.sys.readDirectory), | ||
@@ -299,32 +330,9 @@ getDirectories: (0, lodash_memoize_1.default)(this._ts.sys.getDirectories), | ||
}; | ||
TsCompiler.prototype._doTypeChecking = function (fileName, depGraphs, watchMode) { | ||
var e_1, _a; | ||
TsCompiler.prototype.getDiagnostics = function (fileName) { | ||
var diagnostics = []; | ||
if (this.configSet.shouldReportDiagnostics(fileName)) { | ||
this._logger.debug({ fileName: fileName }, '_doTypeChecking(): computing diagnostics using language service'); | ||
var diagnostics = __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileName)), false), __read(this._languageService.getSyntacticDiagnostics(fileName)), false); | ||
this.configSet.raiseDiagnostics(diagnostics, fileName, this._logger); | ||
diagnostics.push.apply(diagnostics, __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileName)), false), __read(this._languageService.getSyntacticDiagnostics(fileName)), false)); | ||
} | ||
if (watchMode) { | ||
this._logger.debug({ fileName: fileName }, '_doTypeChecking(): starting watch mode computing diagnostics'); | ||
try { | ||
for (var _b = __values(depGraphs.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var entry = _c.value; | ||
var normalizedModuleNames = entry[1].resolvedModuleNames.map(function (moduleName) { return (0, path_1.normalize)(moduleName); }); | ||
var fileToReTypeCheck = entry[0]; | ||
if (normalizedModuleNames.includes(fileName) && this.configSet.shouldReportDiagnostics(fileToReTypeCheck)) { | ||
this._logger.debug({ fileToReTypeCheck: fileToReTypeCheck }, '_doTypeChecking(): computing diagnostics using language service'); | ||
this._updateMemoryCache(this._getFileContentFromCache(fileToReTypeCheck), fileToReTypeCheck); | ||
var importedModulesDiagnostics = __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileToReTypeCheck)), false), __read(this._languageService.getSyntacticDiagnostics(fileToReTypeCheck)), false); | ||
this.configSet.raiseDiagnostics(importedModulesDiagnostics, fileName, this._logger); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
return diagnostics; | ||
}; | ||
@@ -331,0 +339,0 @@ return TsCompiler; |
@@ -1,3 +0,2 @@ | ||
import type { TransformedSource } from '@jest/transform'; | ||
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../../types'; | ||
import type { CompilerInstance, CompiledOutput, StringMap, TsJestCompileOptions } from '../../types'; | ||
import type { ConfigSet } from '../config/config-set'; | ||
@@ -8,3 +7,3 @@ export declare class TsJestCompiler implements CompilerInstance { | ||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[]; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput; | ||
} |
@@ -460,3 +460,3 @@ "use strict"; | ||
return; | ||
var error = this._createTsError(filteredDiagnostics); | ||
var error = this.createTsError(filteredDiagnostics); | ||
var importantCategories = [DiagnosticCategory.Warning, DiagnosticCategory.Error]; | ||
@@ -474,3 +474,3 @@ if (this._diagnostics.throws && filteredDiagnostics.some(function (d) { return importantCategories.includes(d.category); })) { | ||
}; | ||
ConfigSet.prototype._createTsError = function (diagnostics) { | ||
ConfigSet.prototype.createTsError = function (diagnostics) { | ||
var _this = this; | ||
@@ -477,0 +477,0 @@ var formatDiagnostics = this._diagnostics.pretty |
@@ -160,3 +160,5 @@ "use strict"; | ||
var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer; | ||
var result = this.processWithTs(sourceText, sourcePath, transformOptions); | ||
var result = { | ||
code: this.processWithTs(sourceText, sourcePath, transformOptions).code, | ||
}; | ||
if (babelJest) { | ||
@@ -174,6 +176,7 @@ this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor'); | ||
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath); | ||
return [2, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () { | ||
var configs, shouldStringifyContent, babelJest, result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return [2, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
var configs, shouldStringifyContent, babelJest, result, processWithTsResult; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -183,3 +186,9 @@ configs = this._configsFor(transformOptions); | ||
babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer; | ||
result = this.processWithTs(sourceText, sourcePath, transformOptions); | ||
processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions); | ||
result = { | ||
code: processWithTsResult.code, | ||
}; | ||
if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { | ||
reject(configs.createTsError(processWithTsResult.diagnostics)); | ||
} | ||
if (!babelJest) return [3, 2]; | ||
@@ -189,4 +198,4 @@ this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor'); | ||
case 1: | ||
result = _a.sent(); | ||
_a.label = 2; | ||
result = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
@@ -299,5 +308,4 @@ result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2, new Promise(function (resolve) { return resolve(_this.getCacheKey(sourceText, sourcePath, transformOptions)); })]; | ||
return [2, Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions))]; | ||
}); | ||
@@ -304,0 +312,0 @@ }); |
@@ -82,5 +82,8 @@ import type { TransformedSource, TransformOptions } from '@jest/transform'; | ||
} | ||
export interface CompiledOutput extends TransformedSource { | ||
diagnostics?: _ts.Diagnostic[]; | ||
} | ||
export interface CompilerInstance { | ||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[]; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource; | ||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput; | ||
} | ||
@@ -87,0 +90,0 @@ export interface TsCompilerInstance extends CompilerInstance { |
{ | ||
"name": "ts-jest", | ||
"version": "28.0.4", | ||
"version": "28.0.5", | ||
"main": "dist/index.js", | ||
@@ -61,3 +61,3 @@ "types": "dist/index.d.ts", | ||
"semver": "7.x", | ||
"yargs-parser": "^20.x" | ||
"yargs-parser": "^21.0.1" | ||
}, | ||
@@ -91,8 +91,7 @@ "peerDependencies": { | ||
"@commitlint/config-angular": "^17.0.0", | ||
"@jest/transform": "^28.0.0", | ||
"@jest/types": "^28.0.0", | ||
"@jest/transform": "^28.1.1", | ||
"@jest/types": "^28.1.1", | ||
"@types/babel__core": "7.x", | ||
"@types/cross-spawn": "latest", | ||
"@types/fs-extra": "latest", | ||
"@types/jest": "^27.0.3", | ||
"@types/js-yaml": "latest", | ||
@@ -109,9 +108,10 @@ "@types/lodash.camelcase": "4.x", | ||
"@types/yargs": "latest", | ||
"@types/yargs-parser": "20.x", | ||
"@typescript-eslint/eslint-plugin": "^5.3.0", | ||
"@typescript-eslint/parser": "^5.3.0", | ||
"@types/yargs-parser": "21.x", | ||
"@typescript-eslint/eslint-plugin": "^5.27.1", | ||
"@typescript-eslint/parser": "^5.27.1", | ||
"babel-jest": "^28.1.1", | ||
"conventional-changelog-cli": "2.x", | ||
"cross-spawn": "latest", | ||
"esbuild": "~0.14.42", | ||
"eslint": "^8.4.1", | ||
"esbuild": "~0.14.43", | ||
"eslint": "^8.17.0", | ||
"eslint-config-prettier": "latest", | ||
@@ -128,12 +128,12 @@ "eslint-plugin-import": "latest", | ||
"husky": "4.x", | ||
"jest": "^28.0.0", | ||
"jest": "^28.1.1", | ||
"jest-snapshot-serializer-raw": "^1.2.0", | ||
"js-yaml": "latest", | ||
"json-schema-to-typescript": "^10.1.4", | ||
"json-schema-to-typescript": "^10.1.5", | ||
"lint-staged": "latest", | ||
"lodash.camelcase": "^4.3.0", | ||
"lodash.set": "^4.3.2", | ||
"node-fetch": "^3.0.0", | ||
"prettier": "^2.4.0", | ||
"typescript": "~4.6.2" | ||
"node-fetch": "^3.2.6", | ||
"prettier": "^2.6.2", | ||
"typescript": "~4.7.3" | ||
}, | ||
@@ -140,0 +140,0 @@ "lint-staged": { |
{ | ||
"extends": [ | ||
":dependencyDashboard", | ||
"group:babelMonorepo", | ||
@@ -8,3 +7,4 @@ "group:commitlintMonorepo", | ||
":prHourlyLimit2", | ||
"workarounds:all" | ||
"workarounds:all", | ||
"helpers:pinGitHubActionDigests" | ||
], | ||
@@ -57,6 +57,3 @@ "timezone": "UTC", | ||
"matchPaths": ["e2e/**"], | ||
"matchPackageNames": [ | ||
"react", | ||
"react-intl" | ||
], | ||
"matchPackagePatterns": ["react"], | ||
"groupName": "React e2e packages", | ||
@@ -63,0 +60,0 @@ "enabled": true |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
262617
93
3278
+ Addedelectron-to-chromium@1.4.773(transitive)
- Removedelectron-to-chromium@1.4.772(transitive)
- Removedyargs-parser@20.2.9(transitive)
Updatedyargs-parser@^21.0.1