Set up comprehensive frontend testing infrastructure
- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
6
frontend/node_modules/ts-jest/dist/cli/config/init.d.ts
generated
vendored
Normal file
6
frontend/node_modules/ts-jest/dist/cli/config/init.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This has been written quickly. While trying to improve I realised it'd be better to have it in Jest...
|
||||
* ...and I saw a merged PR with `jest --init` tool!
|
||||
* TODO: see what's the best path for this
|
||||
*/
|
||||
export {};
|
||||
138
frontend/node_modules/ts-jest/dist/cli/config/init.js
generated
vendored
Normal file
138
frontend/node_modules/ts-jest/dist/cli/config/init.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This has been written quickly. While trying to improve I realised it'd be better to have it in Jest...
|
||||
* ...and I saw a merged PR with `jest --init` tool!
|
||||
* TODO: see what's the best path for this
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const ejs_1 = __importDefault(require("ejs"));
|
||||
const json5_1 = require("json5");
|
||||
const create_jest_preset_1 = require("../../presets/create-jest-preset");
|
||||
const JEST_CONFIG_EJS_TEMPLATE = `const { <%= presetCreatorFn %> } = require("ts-jest");
|
||||
|
||||
const tsJestTransformCfg = <%= presetCreatorFn %>(<%- transformOpts %>).transform;
|
||||
|
||||
/** @type {import("jest").Config} **/
|
||||
<%= exportKind %> {
|
||||
testEnvironment: "<%= testEnvironment %>",
|
||||
transform: {
|
||||
...tsJestTransformCfg,
|
||||
},
|
||||
};`;
|
||||
const ensureOnlyUsingDoubleQuotes = (str) => {
|
||||
return str
|
||||
.replace(/"'(.*?)'"/g, '"$1"')
|
||||
.replace(/'ts-jest'/g, '"ts-jest"')
|
||||
.replace(/'babel-jest'/g, '"babel-jest"');
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (args /* , logger: Logger */) => {
|
||||
const { tsconfig: askedTsconfig, force, jsdom, js: jsFilesProcessor, babel: shouldPostProcessWithBabel } = args;
|
||||
const file = args._[0]?.toString() ?? 'jest.config.js';
|
||||
const filePath = (0, path_1.join)(process.cwd(), file);
|
||||
const name = (0, path_1.basename)(file);
|
||||
const isPackageJsonConfig = name === 'package.json';
|
||||
const isJestConfigFileExisted = (0, fs_1.existsSync)(filePath);
|
||||
const pkgFile = isPackageJsonConfig ? filePath : (0, path_1.join)(process.cwd(), 'package.json');
|
||||
const isPackageJsonExisted = isPackageJsonConfig || (0, fs_1.existsSync)(pkgFile);
|
||||
const tsconfig = askedTsconfig === 'tsconfig.json' ? undefined : askedTsconfig;
|
||||
const pkgJsonContent = isPackageJsonExisted ? JSON.parse((0, fs_1.readFileSync)(pkgFile, 'utf8')) : {};
|
||||
if (shouldPostProcessWithBabel) {
|
||||
console.warn(`The option --babel is deprecated and will be removed in the next major version.` +
|
||||
` Please specify 'js' option value (see more with npx ts-jest help) if you wish 'ts-jest' to process 'js' with TypeScript API or Babel.`);
|
||||
}
|
||||
if (isPackageJsonConfig && !isJestConfigFileExisted) {
|
||||
throw new Error(`File ${file} does not exists.`);
|
||||
}
|
||||
else if (!isPackageJsonConfig && isJestConfigFileExisted && !force) {
|
||||
throw new Error(`Configuration file ${file} already exists.`);
|
||||
}
|
||||
if (!isPackageJsonConfig && !name.endsWith('.js')) {
|
||||
throw new TypeError(`Configuration file ${file} must be a .js file or the package.json.`);
|
||||
}
|
||||
if (isPackageJsonExisted && pkgJsonContent.jest) {
|
||||
if (force && !isPackageJsonConfig) {
|
||||
delete pkgJsonContent.jest;
|
||||
(0, fs_1.writeFileSync)(pkgFile, JSON.stringify(pkgJsonContent, undefined, ' '));
|
||||
}
|
||||
else if (!force) {
|
||||
throw new Error(`A Jest configuration is already set in ${pkgFile}.`);
|
||||
}
|
||||
}
|
||||
let body;
|
||||
const transformOpts = tsconfig
|
||||
? { tsconfig: `${(0, json5_1.stringify)(tsconfig)}` }
|
||||
: undefined;
|
||||
let transformConfig;
|
||||
if (isPackageJsonConfig) {
|
||||
if (jsFilesProcessor === 'babel' || shouldPostProcessWithBabel) {
|
||||
transformConfig = (0, create_jest_preset_1.createJsWithBabelPreset)(transformOpts);
|
||||
}
|
||||
else if (jsFilesProcessor === 'ts') {
|
||||
transformConfig = (0, create_jest_preset_1.createJsWithTsPreset)(transformOpts);
|
||||
}
|
||||
else {
|
||||
transformConfig = (0, create_jest_preset_1.createDefaultPreset)(transformOpts);
|
||||
}
|
||||
body = ensureOnlyUsingDoubleQuotes(JSON.stringify({
|
||||
...pkgJsonContent,
|
||||
jest: transformConfig,
|
||||
}, undefined, ' '));
|
||||
}
|
||||
else {
|
||||
let presetCreatorFn;
|
||||
if (jsFilesProcessor === 'babel' || shouldPostProcessWithBabel) {
|
||||
presetCreatorFn = 'createJsWithBabelPreset';
|
||||
}
|
||||
else if (jsFilesProcessor === 'ts') {
|
||||
presetCreatorFn = 'createJsWithTsPreset';
|
||||
}
|
||||
else {
|
||||
presetCreatorFn = 'createDefaultPreset';
|
||||
}
|
||||
body = ejs_1.default.render(JEST_CONFIG_EJS_TEMPLATE, {
|
||||
exportKind: pkgJsonContent.type === 'module' ? 'export default' : 'module.exports =',
|
||||
testEnvironment: jsdom ? 'jsdom' : 'node',
|
||||
presetCreatorFn,
|
||||
transformOpts: transformOpts ? ensureOnlyUsingDoubleQuotes(JSON.stringify(transformOpts, null, 2)) : undefined,
|
||||
});
|
||||
}
|
||||
(0, fs_1.writeFileSync)(filePath, body);
|
||||
process.stderr.write(`
|
||||
Jest configuration written to "${filePath}".
|
||||
`);
|
||||
};
|
||||
exports.run = run;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const help = async () => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest config:init [options] [<config-file>]
|
||||
|
||||
Arguments:
|
||||
<config-file> Can be a js or json Jest config file. If it is a
|
||||
package.json file, the configuration will be read from
|
||||
the "jest" property.
|
||||
Default: jest.config.js
|
||||
|
||||
Options:
|
||||
--force Discard any existing Jest config
|
||||
--js ts|babel Process '.js' files with ts-jest if 'ts' or with
|
||||
babel-jest if 'babel'
|
||||
--no-jest-preset Disable the use of Jest presets
|
||||
--tsconfig <file> Path to the tsconfig.json file
|
||||
--babel Enable using Babel to process 'js' resulted content from 'ts-jest' processing
|
||||
--jsdom Use 'jsdom' as test environment instead of 'node'
|
||||
`);
|
||||
};
|
||||
exports.help = help;
|
||||
1
frontend/node_modules/ts-jest/dist/cli/config/migrate.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/cli/config/migrate.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
174
frontend/node_modules/ts-jest/dist/cli/config/migrate.js
generated
vendored
Normal file
174
frontend/node_modules/ts-jest/dist/cli/config/migrate.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
||||
const json5_1 = require("json5");
|
||||
const create_jest_preset_1 = require("../../presets/create-jest-preset");
|
||||
const backports_1 = require("../../utils/backports");
|
||||
const presets_1 = require("../helpers/presets");
|
||||
const migrateGlobalConfigToTransformConfig = (transformConfig, globalsTsJestConfig) => {
|
||||
if (transformConfig) {
|
||||
return Object.entries(transformConfig).reduce((previousValue, currentValue) => {
|
||||
const [key, transformOptions] = currentValue;
|
||||
if (typeof transformOptions === 'string' && transformOptions.includes('ts-jest')) {
|
||||
return {
|
||||
...previousValue,
|
||||
[key]: globalsTsJestConfig ? ['ts-jest', globalsTsJestConfig] : 'ts-jest',
|
||||
};
|
||||
}
|
||||
return {
|
||||
...previousValue,
|
||||
[key]: transformOptions,
|
||||
};
|
||||
}, {});
|
||||
}
|
||||
return {};
|
||||
};
|
||||
const migratePresetToTransformConfig = (transformConfig, preset, globalsTsJestConfig) => {
|
||||
if (preset) {
|
||||
const transformConfigFromPreset = preset.name === "ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */
|
||||
? (0, create_jest_preset_1.createJsWithTsPreset)(globalsTsJestConfig)
|
||||
: preset.name === "ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */
|
||||
? (0, create_jest_preset_1.createJsWithBabelPreset)(globalsTsJestConfig)
|
||||
: (0, create_jest_preset_1.createDefaultPreset)(globalsTsJestConfig);
|
||||
return {
|
||||
...transformConfig,
|
||||
...transformConfigFromPreset.transform,
|
||||
};
|
||||
}
|
||||
return transformConfig;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (args /* , logger: Logger*/) => {
|
||||
const nullLogger = (0, bs_logger_1.createLogger)({ targets: [] });
|
||||
const file = args._[0]?.toString();
|
||||
const filePath = (0, path_1.resolve)(process.cwd(), file);
|
||||
if (!(0, fs_1.existsSync)(filePath)) {
|
||||
throw new Error(`Configuration file ${file} does not exists.`);
|
||||
}
|
||||
const name = (0, path_1.basename)(file);
|
||||
const isPackage = name === 'package.json';
|
||||
if (!/\.(js|json)$/.test(name)) {
|
||||
throw new TypeError(`Configuration file ${file} must be a JavaScript or JSON file.`);
|
||||
}
|
||||
let actualConfig = require(filePath);
|
||||
if (isPackage) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
actualConfig = actualConfig.jest;
|
||||
}
|
||||
if (!actualConfig)
|
||||
actualConfig = {};
|
||||
// migrate
|
||||
// first we backport our options
|
||||
const migratedConfig = (0, backports_1.backportJestConfig)(nullLogger, actualConfig);
|
||||
let preset;
|
||||
if (migratedConfig.preset) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
preset = presets_1.allPresets[migratedConfig.preset] ?? presets_1.allPresets["ts-jest/presets/default" /* JestPresetNames.default */];
|
||||
}
|
||||
else {
|
||||
if (args.js) {
|
||||
preset = args.js === 'babel' ? presets_1.allPresets["ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */] : presets_1.allPresets["ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */];
|
||||
}
|
||||
else {
|
||||
preset = presets_1.allPresets["ts-jest/presets/default" /* JestPresetNames.default */];
|
||||
}
|
||||
}
|
||||
// check the extensions
|
||||
if (migratedConfig.moduleFileExtensions?.length && preset) {
|
||||
const presetValue = dedupSort(preset.value.moduleFileExtensions ?? []).join('::');
|
||||
const migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::');
|
||||
if (presetValue === migratedValue) {
|
||||
delete migratedConfig.moduleFileExtensions;
|
||||
}
|
||||
}
|
||||
// there is a testRegex, remove our testMatch
|
||||
if (typeof migratedConfig.testRegex === 'string' || migratedConfig.testRegex?.length) {
|
||||
delete migratedConfig.testMatch;
|
||||
}
|
||||
// check the testMatch
|
||||
else if (migratedConfig.testMatch?.length && preset) {
|
||||
const presetValue = dedupSort(preset.value.testMatch ?? []).join('::');
|
||||
const migratedValue = dedupSort(migratedConfig.testMatch).join('::');
|
||||
if (presetValue === migratedValue) {
|
||||
delete migratedConfig.testMatch;
|
||||
}
|
||||
}
|
||||
const globalsTsJestConfig = migratedConfig.globals?.['ts-jest'];
|
||||
migratedConfig.transform = migrateGlobalConfigToTransformConfig(migratedConfig.transform, globalsTsJestConfig);
|
||||
migratedConfig.transform = migratePresetToTransformConfig(migratedConfig.transform, preset, globalsTsJestConfig);
|
||||
cleanupConfig(actualConfig);
|
||||
cleanupConfig(migratedConfig);
|
||||
const before = (0, fast_json_stable_stringify_1.default)(actualConfig);
|
||||
const after = (0, fast_json_stable_stringify_1.default)(migratedConfig);
|
||||
if (after === before) {
|
||||
process.stderr.write(`
|
||||
No migration needed for given Jest configuration
|
||||
`);
|
||||
return;
|
||||
}
|
||||
const stringify = file.endsWith('.json') ? JSON.stringify : json5_1.stringify;
|
||||
const prefix = file.endsWith('.json') ? '"jest": ' : 'module.exports = ';
|
||||
// output new config
|
||||
process.stderr.write(`
|
||||
Migrated Jest configuration:
|
||||
`);
|
||||
process.stdout.write(`${prefix}${stringify(migratedConfig, undefined, ' ')}\n`);
|
||||
};
|
||||
exports.run = run;
|
||||
function cleanupConfig(config) {
|
||||
if (config.globals) {
|
||||
delete config.globals['ts-jest'];
|
||||
if (!Object.keys(config.globals).length) {
|
||||
delete config.globals;
|
||||
}
|
||||
}
|
||||
if (config.transform && !Object.keys(config.transform).length) {
|
||||
delete config.transform;
|
||||
}
|
||||
if (config.moduleFileExtensions) {
|
||||
config.moduleFileExtensions = dedupSort(config.moduleFileExtensions);
|
||||
if (!config.moduleFileExtensions.length)
|
||||
delete config.moduleFileExtensions;
|
||||
}
|
||||
if (config.testMatch) {
|
||||
config.testMatch = dedupSort(config.testMatch);
|
||||
if (!config.testMatch.length)
|
||||
delete config.testMatch;
|
||||
}
|
||||
delete config.preset;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function dedupSort(arr) {
|
||||
return arr
|
||||
.filter((s, i, a) => a.findIndex((e) => s.toString() === e.toString()) === i)
|
||||
.sort((a, b) => (a.toString() > b.toString() ? 1 : a.toString() < b.toString() ? -1 : 0));
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const help = async () => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest config:migrate [options] <config-file>
|
||||
|
||||
Arguments:
|
||||
<config-file> Can be a js or json Jest config file. If it is a
|
||||
package.json file, the configuration will be read from
|
||||
the "jest" property.
|
||||
|
||||
Options:
|
||||
--js ts|babel Process .js files with ts-jest if 'ts' or with
|
||||
babel-jest if 'babel'
|
||||
--no-jest-preset Disable the use of Jest presets
|
||||
`);
|
||||
};
|
||||
exports.help = help;
|
||||
1
frontend/node_modules/ts-jest/dist/cli/help.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/cli/help.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
25
frontend/node_modules/ts-jest/dist/cli/help.js
generated
vendored
Normal file
25
frontend/node_modules/ts-jest/dist/cli/help.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (_) => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest command [options] [...args]
|
||||
|
||||
Commands:
|
||||
config:init Creates initial Jest configuration
|
||||
config:migrate Migrates a given Jest configuration
|
||||
help [command] Show this help, or help about a command
|
||||
|
||||
Example:
|
||||
ts-jest help config:migrate
|
||||
`);
|
||||
};
|
||||
exports.run = run;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.help = exports.run;
|
||||
1
frontend/node_modules/ts-jest/dist/cli/helpers/presets.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/cli/helpers/presets.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
41
frontend/node_modules/ts-jest/dist/cli/helpers/presets.js
generated
vendored
Normal file
41
frontend/node_modules/ts-jest/dist/cli/helpers/presets.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.jsWIthBabel = exports.jsWithTs = exports.defaults = exports.allPresets = void 0;
|
||||
const definePreset = (fullName) => ({
|
||||
fullName,
|
||||
get name() {
|
||||
return this.isDefault ? 'ts-jest' : fullName;
|
||||
},
|
||||
get label() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
return fullName.split('/').pop();
|
||||
},
|
||||
get jsVarName() {
|
||||
return this.isDefault
|
||||
? 'defaults'
|
||||
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
fullName
|
||||
.split('/')
|
||||
.pop()
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
.replace(/\-([a-z])/g, (_, l) => l.toUpperCase());
|
||||
},
|
||||
get value() {
|
||||
return require(`../../../${fullName.replace(/^ts-jest\//, '')}/jest-preset`);
|
||||
},
|
||||
jsImport(varName = 'tsjPreset') {
|
||||
return `const { ${this.jsVarName}: ${varName} } = require('ts-jest/presets')`;
|
||||
},
|
||||
get isDefault() {
|
||||
return fullName === "ts-jest/presets/default" /* JestPresetNames.default */;
|
||||
},
|
||||
});
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
exports.allPresets = {};
|
||||
/** @internal */
|
||||
exports.defaults = (exports.allPresets["ts-jest/presets/default" /* JestPresetNames.default */] = definePreset("ts-jest/presets/default" /* JestPresetNames.default */));
|
||||
/** @internal */
|
||||
exports.jsWithTs = (exports.allPresets["ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */] = definePreset("ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */));
|
||||
/** @internal */
|
||||
exports.jsWIthBabel = (exports.allPresets["ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */] = definePreset("ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */));
|
||||
1
frontend/node_modules/ts-jest/dist/cli/index.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/cli/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
63
frontend/node_modules/ts-jest/dist/cli/index.js
generated
vendored
Normal file
63
frontend/node_modules/ts-jest/dist/cli/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.processArgv = processArgv;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
||||
const utils_1 = require("../utils");
|
||||
const VALID_COMMANDS = ['help', 'config:migrate', 'config:init'];
|
||||
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'cli', [bs_logger_1.LogContexts.application]: 'ts-jest' });
|
||||
async function cli(args) {
|
||||
const parsedArgv = (0, yargs_parser_1.default)(args, {
|
||||
boolean: ['dry-run', 'jest-preset', 'allow-js', 'diff', 'babel', 'force', 'jsdom'],
|
||||
string: ['tsconfig', 'js'],
|
||||
count: ['verbose'],
|
||||
alias: { verbose: ['v'] },
|
||||
default: { jestPreset: true, verbose: 0 },
|
||||
coerce: {
|
||||
js(val) {
|
||||
const res = val.trim().toLowerCase();
|
||||
if (!['babel', 'ts'].includes(res))
|
||||
throw new Error(`The 'js' option must be 'babel' or 'ts', given: '${val}'.`);
|
||||
return res;
|
||||
},
|
||||
},
|
||||
});
|
||||
// deprecated
|
||||
if (parsedArgv.allowJs != null) {
|
||||
if (parsedArgv.js)
|
||||
throw new Error("The 'allowJs' and 'js' options cannot be set together.");
|
||||
parsedArgv.js = parsedArgv.allowJs ? 'ts' : undefined;
|
||||
}
|
||||
let command = parsedArgv._.shift();
|
||||
const isHelp = command === 'help';
|
||||
if (isHelp)
|
||||
command = parsedArgv._.shift();
|
||||
if (!VALID_COMMANDS.includes(command))
|
||||
command = 'help';
|
||||
const { run, help } = require(`./${command.replace(/:/g, '/')}`);
|
||||
const cmd = isHelp && command !== 'help' ? help : run;
|
||||
return cmd(parsedArgv, logger);
|
||||
}
|
||||
const errorHasMessage = (err) => {
|
||||
if (typeof err !== 'object' || err === null)
|
||||
return false;
|
||||
return 'message' in err;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async function processArgv() {
|
||||
try {
|
||||
await cli(process.argv.slice(2));
|
||||
process.exit(0);
|
||||
}
|
||||
catch (err) {
|
||||
if (errorHasMessage(err)) {
|
||||
logger.fatal(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
frontend/node_modules/ts-jest/dist/config/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/config/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './paths-to-module-name-mapper';
|
||||
export * from './types';
|
||||
18
frontend/node_modules/ts-jest/dist/config/index.js
generated
vendored
Normal file
18
frontend/node_modules/ts-jest/dist/config/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./paths-to-module-name-mapper"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
9
frontend/node_modules/ts-jest/dist/config/paths-to-module-name-mapper.d.ts
generated
vendored
Normal file
9
frontend/node_modules/ts-jest/dist/config/paths-to-module-name-mapper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Config } from '@jest/types';
|
||||
import type { CompilerOptions } from 'typescript';
|
||||
type TsPathMapping = Exclude<CompilerOptions['paths'], undefined>;
|
||||
type JestPathMapping = Config.InitialOptions['moduleNameMapper'];
|
||||
export declare const pathsToModuleNameMapper: (mapping: TsPathMapping, { prefix, useESM }?: {
|
||||
prefix?: string;
|
||||
useESM?: boolean;
|
||||
}) => JestPathMapping;
|
||||
export {};
|
||||
52
frontend/node_modules/ts-jest/dist/config/paths-to-module-name-mapper.js
generated
vendored
Normal file
52
frontend/node_modules/ts-jest/dist/config/paths-to-module-name-mapper.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pathsToModuleNameMapper = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const utils_1 = require("../utils");
|
||||
const messages_1 = require("../utils/messages");
|
||||
// we don't need to escape all chars, so commented out is the real one
|
||||
// const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
const escapeRegex = (str) => str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'path-mapper' });
|
||||
const pathsToModuleNameMapper = (mapping, { prefix = '', useESM = false } = {}) => {
|
||||
const jestMap = {};
|
||||
for (const fromPath of Object.keys(mapping)) {
|
||||
const toPaths = mapping[fromPath];
|
||||
// check that we have only one target path
|
||||
if (toPaths.length === 0) {
|
||||
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has no target." /* Errors.NotMappingPathWithEmptyMap */, { path: fromPath }));
|
||||
continue;
|
||||
}
|
||||
// split with '*'
|
||||
const segments = fromPath.split(/\*/g);
|
||||
if (segments.length === 1) {
|
||||
const paths = toPaths.map((target) => {
|
||||
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
||||
return `${enrichedPrefix}${target}`;
|
||||
});
|
||||
const cjsPattern = `^${escapeRegex(fromPath)}$`;
|
||||
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
else if (segments.length === 2) {
|
||||
const paths = toPaths.map((target) => {
|
||||
const enrichedTarget = target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target;
|
||||
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
||||
return `${enrichedPrefix}${enrichedTarget.replace(/\*/g, '$1')}`;
|
||||
});
|
||||
if (useESM) {
|
||||
const esmPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}\\.js$`;
|
||||
jestMap[esmPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
const cjsPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}$`;
|
||||
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
else {
|
||||
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has more than one star (`*`)." /* Errors.NotMappingMultiStarPath */, { path: fromPath }));
|
||||
}
|
||||
}
|
||||
if (useESM) {
|
||||
jestMap['^(\\.{1,2}/.*)\\.js$'] = '$1';
|
||||
}
|
||||
return jestMap;
|
||||
};
|
||||
exports.pathsToModuleNameMapper = pathsToModuleNameMapper;
|
||||
2
frontend/node_modules/ts-jest/dist/config/types.d.ts
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/config/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { TsConfigJson } from 'type-fest';
|
||||
export type TsConfigCompilerOptionsJson = TsConfigJson.CompilerOptions;
|
||||
2
frontend/node_modules/ts-jest/dist/config/types.js
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/config/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
13
frontend/node_modules/ts-jest/dist/constants.d.ts
generated
vendored
Normal file
13
frontend/node_modules/ts-jest/dist/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export declare const LINE_FEED = "\n";
|
||||
export declare const DECLARATION_TYPE_EXT = ".d.ts";
|
||||
export declare const JS_JSX_EXTENSIONS: string[];
|
||||
export declare const TS_TSX_REGEX: RegExp;
|
||||
export declare const JS_JSX_REGEX: RegExp;
|
||||
export declare const TS_TRANSFORM_PATTERN = "^.+\\.tsx?$";
|
||||
export declare const ESM_TS_TRANSFORM_PATTERN = "^.+\\.m?tsx?$";
|
||||
export declare const TS_JS_TRANSFORM_PATTERN = "^.+\\.[tj]sx?$";
|
||||
export declare const ESM_TS_JS_TRANSFORM_PATTERN = "^.+\\.m?[tj]sx?$";
|
||||
export declare const JS_TRANSFORM_PATTERN = "^.+\\.jsx?$";
|
||||
export declare const ESM_JS_TRANSFORM_PATTERN = "^.+\\.m?jsx?$";
|
||||
export declare const TS_EXT_TO_TREAT_AS_ESM: string[];
|
||||
export declare const JS_EXT_TO_TREAT_AS_ESM: string[];
|
||||
22
frontend/node_modules/ts-jest/dist/constants.js
generated
vendored
Normal file
22
frontend/node_modules/ts-jest/dist/constants.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DEFAULT_JEST_TEST_MATCH = exports.JS_EXT_TO_TREAT_AS_ESM = exports.TS_EXT_TO_TREAT_AS_ESM = exports.ESM_JS_TRANSFORM_PATTERN = exports.JS_TRANSFORM_PATTERN = exports.ESM_TS_JS_TRANSFORM_PATTERN = exports.TS_JS_TRANSFORM_PATTERN = exports.ESM_TS_TRANSFORM_PATTERN = exports.TS_TRANSFORM_PATTERN = exports.JS_JSX_REGEX = exports.TS_TSX_REGEX = exports.JS_JSX_EXTENSIONS = exports.DECLARATION_TYPE_EXT = exports.LINE_FEED = void 0;
|
||||
exports.LINE_FEED = '\n';
|
||||
exports.DECLARATION_TYPE_EXT = '.d.ts';
|
||||
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
|
||||
exports.TS_TSX_REGEX = /\.[cm]?tsx?$/;
|
||||
exports.JS_JSX_REGEX = /\.[cm]?jsx?$/;
|
||||
exports.TS_TRANSFORM_PATTERN = '^.+\\.tsx?$';
|
||||
exports.ESM_TS_TRANSFORM_PATTERN = '^.+\\.m?tsx?$';
|
||||
exports.TS_JS_TRANSFORM_PATTERN = '^.+\\.[tj]sx?$';
|
||||
exports.ESM_TS_JS_TRANSFORM_PATTERN = '^.+\\.m?[tj]sx?$';
|
||||
exports.JS_TRANSFORM_PATTERN = '^.+\\.jsx?$';
|
||||
exports.ESM_JS_TRANSFORM_PATTERN = '^.+\\.m?jsx?$';
|
||||
// `extensionsToTreatAsEsm` will throw error with `.mjs`
|
||||
exports.TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts'];
|
||||
exports.JS_EXT_TO_TREAT_AS_ESM = ['.jsx'];
|
||||
/**
|
||||
* @internal
|
||||
* See https://jestjs.io/docs/en/configuration#testmatch-arraystring
|
||||
*/
|
||||
exports.DEFAULT_JEST_TEST_MATCH = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
||||
15
frontend/node_modules/ts-jest/dist/index.d.ts
generated
vendored
Normal file
15
frontend/node_modules/ts-jest/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TsJestTransformer } from './legacy/ts-jest-transformer';
|
||||
import type { TsJestTransformerOptions } from './types';
|
||||
export * from './config';
|
||||
export * from './constants';
|
||||
export * from './legacy/compiler';
|
||||
export * from './legacy/ts-jest-transformer';
|
||||
export * from './legacy/config/config-set';
|
||||
export * from './presets/create-jest-preset';
|
||||
export * from './raw-compiler-options';
|
||||
export * from './utils';
|
||||
export * from './types';
|
||||
declare const _default: {
|
||||
createTransformer(tsJestConfig?: TsJestTransformerOptions): TsJestTransformer;
|
||||
};
|
||||
export default _default;
|
||||
31
frontend/node_modules/ts-jest/dist/index.js
generated
vendored
Normal file
31
frontend/node_modules/ts-jest/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ts_jest_transformer_1 = require("./legacy/ts-jest-transformer");
|
||||
__exportStar(require("./config"), exports);
|
||||
__exportStar(require("./constants"), exports);
|
||||
__exportStar(require("./legacy/compiler"), exports);
|
||||
__exportStar(require("./legacy/ts-jest-transformer"), exports);
|
||||
__exportStar(require("./legacy/config/config-set"), exports);
|
||||
__exportStar(require("./presets/create-jest-preset"), exports);
|
||||
__exportStar(require("./raw-compiler-options"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
exports.default = {
|
||||
createTransformer(tsJestConfig) {
|
||||
return new ts_jest_transformer_1.TsJestTransformer(tsJestConfig);
|
||||
},
|
||||
};
|
||||
8
frontend/node_modules/ts-jest/dist/legacy/compiler/compiler-utils.d.ts
generated
vendored
Normal file
8
frontend/node_modules/ts-jest/dist/legacy/compiler/compiler-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
|
||||
*/
|
||||
export declare const SOURCE_MAPPING_PREFIX = "sourceMappingURL=";
|
||||
/**
|
||||
* Update the output remapping the source map.
|
||||
*/
|
||||
export declare function updateOutput(outputText: string, normalizedFileName: string, sourceMap?: string): string;
|
||||
32
frontend/node_modules/ts-jest/dist/legacy/compiler/compiler-utils.js
generated
vendored
Normal file
32
frontend/node_modules/ts-jest/dist/legacy/compiler/compiler-utils.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SOURCE_MAPPING_PREFIX = void 0;
|
||||
exports.updateOutput = updateOutput;
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
|
||||
*/
|
||||
exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
||||
/**
|
||||
* Update the output remapping the source map.
|
||||
*/
|
||||
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
||||
if (sourceMap) {
|
||||
const base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
||||
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`;
|
||||
// sourceMappingURL= prefix is always at the end of compiledOutput, using lastIndexOf should be the safest way to substring
|
||||
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) +
|
||||
sourceMapContent);
|
||||
}
|
||||
return outputText;
|
||||
}
|
||||
/**
|
||||
* Update the source map contents for improved output.
|
||||
*/
|
||||
const updateSourceMap = (sourceMapText, normalizedFileName) => {
|
||||
const sourceMap = JSON.parse(sourceMapText);
|
||||
sourceMap.file = normalizedFileName;
|
||||
sourceMap.sources = [normalizedFileName];
|
||||
delete sourceMap.sourceRoot;
|
||||
return (0, utils_1.stringify)(sourceMap);
|
||||
};
|
||||
2
frontend/node_modules/ts-jest/dist/legacy/compiler/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/legacy/compiler/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './ts-compiler';
|
||||
export * from './ts-jest-compiler';
|
||||
18
frontend/node_modules/ts-jest/dist/legacy/compiler/index.js
generated
vendored
Normal file
18
frontend/node_modules/ts-jest/dist/legacy/compiler/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./ts-compiler"), exports);
|
||||
__exportStar(require("./ts-jest-compiler"), exports);
|
||||
27
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.d.ts
generated
vendored
Normal file
27
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Logger } from 'bs-logger';
|
||||
import { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
|
||||
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript, CompiledOutput } from '../../types';
|
||||
import type { ConfigSet } from '../config/config-set';
|
||||
export declare class TsCompiler implements TsCompilerInstance {
|
||||
readonly configSet: ConfigSet;
|
||||
readonly runtimeCacheFS: StringMap;
|
||||
protected readonly _logger: Logger;
|
||||
protected readonly _ts: TTypeScript;
|
||||
protected readonly _initialCompilerOptions: CompilerOptions;
|
||||
protected _compilerOptions: CompilerOptions;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
private _runtimeCacheFS;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
private _fileContentCache;
|
||||
program: Program | undefined;
|
||||
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
||||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
||||
private fixupCompilerOptionsForModuleKind;
|
||||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
|
||||
protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
|
||||
protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
|
||||
}
|
||||
425
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js
generated
vendored
Normal file
425
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js
generated
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsCompiler = void 0;
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const constants_1 = require("../../constants");
|
||||
const transpile_module_1 = require("../../transpilers/typescript/transpile-module");
|
||||
const utils_1 = require("../../utils");
|
||||
const messages_1 = require("../../utils/messages");
|
||||
const compiler_utils_1 = require("./compiler-utils");
|
||||
const assertCompilerOptionsWithJestTransformMode = (compilerOptions, isEsmMode, logger) => {
|
||||
if (isEsmMode && compilerOptions.module === typescript_1.default.ModuleKind.CommonJS) {
|
||||
logger.error("The current compiler option \"module\" value is not suitable for Jest ESM mode. Please either use ES module kinds or Node16/NodeNext module kinds with \"type: module\" in package.json" /* Errors.InvalidModuleKindForEsm */);
|
||||
}
|
||||
};
|
||||
class TsCompiler {
|
||||
configSet;
|
||||
runtimeCacheFS;
|
||||
_logger;
|
||||
_ts;
|
||||
_initialCompilerOptions;
|
||||
_compilerOptions;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_runtimeCacheFS;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_fileContentCache;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_parsedTsConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_fileVersionCache;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_cachedReadFile;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_projectVersion = 1;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_languageService;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_moduleResolutionHost;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_moduleResolutionCache;
|
||||
program;
|
||||
constructor(configSet, runtimeCacheFS) {
|
||||
this.configSet = configSet;
|
||||
this.runtimeCacheFS = runtimeCacheFS;
|
||||
this._ts = configSet.compilerModule;
|
||||
this._logger = utils_1.rootLogger.child({ namespace: 'ts-compiler' });
|
||||
this._parsedTsConfig = this.configSet.parsedTsConfig;
|
||||
this._initialCompilerOptions = { ...this._parsedTsConfig.options };
|
||||
this._compilerOptions = { ...this._initialCompilerOptions };
|
||||
this._runtimeCacheFS = runtimeCacheFS;
|
||||
if (!this.configSet.isolatedModules) {
|
||||
this._fileContentCache = new Map();
|
||||
this._fileVersionCache = new Map();
|
||||
this._cachedReadFile = this._logger.wrap({
|
||||
namespace: 'ts:serviceHost',
|
||||
call: null,
|
||||
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
||||
}, 'readFile', (0, lodash_memoize_1.default)(this._ts.sys.readFile));
|
||||
/* istanbul ignore next */
|
||||
this._moduleResolutionHost = {
|
||||
fileExists: (0, lodash_memoize_1.default)(this._ts.sys.fileExists),
|
||||
readFile: this._cachedReadFile,
|
||||
directoryExists: (0, lodash_memoize_1.default)(this._ts.sys.directoryExists),
|
||||
getCurrentDirectory: () => this.configSet.cwd,
|
||||
realpath: this._ts.sys.realpath && (0, lodash_memoize_1.default)(this._ts.sys.realpath),
|
||||
getDirectories: (0, lodash_memoize_1.default)(this._ts.sys.getDirectories),
|
||||
useCaseSensitiveFileNames: () => this._ts.sys.useCaseSensitiveFileNames,
|
||||
};
|
||||
this._moduleResolutionCache = this._ts.createModuleResolutionCache(this.configSet.cwd, this._ts.sys.useCaseSensitiveFileNames ? (x) => x : (x) => x.toLowerCase(), this._compilerOptions);
|
||||
this._createLanguageService();
|
||||
}
|
||||
}
|
||||
getResolvedModules(fileContent, fileName, runtimeCacheFS) {
|
||||
// In watch mode, it is possible that the initial cacheFS becomes empty
|
||||
if (!this.runtimeCacheFS.size) {
|
||||
this._runtimeCacheFS = runtimeCacheFS;
|
||||
}
|
||||
this._logger.debug({ fileName }, 'getResolvedModules(): resolve direct imported module paths');
|
||||
const importedModulePaths = Array.from(new Set(this._getImportedModulePaths(fileContent, fileName)));
|
||||
this._logger.debug({ fileName }, 'getResolvedModules(): resolve nested imported module paths from directed imported module paths');
|
||||
importedModulePaths.forEach((importedModulePath) => {
|
||||
const resolvedFileContent = this._getFileContentFromCache(importedModulePath);
|
||||
importedModulePaths.push(...this._getImportedModulePaths(resolvedFileContent, importedModulePath).filter((modulePath) => !importedModulePaths.includes(modulePath)));
|
||||
});
|
||||
return importedModulePaths;
|
||||
}
|
||||
fixupCompilerOptionsForModuleKind(compilerOptions, isEsm) {
|
||||
const moduleResolution = this._ts.ModuleResolutionKind.Node10 ?? this._ts.ModuleResolutionKind.NodeJs;
|
||||
if (!isEsm) {
|
||||
return {
|
||||
...compilerOptions,
|
||||
module: this._ts.ModuleKind.CommonJS,
|
||||
moduleResolution,
|
||||
/**
|
||||
* This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
|
||||
*/
|
||||
customConditions: undefined,
|
||||
};
|
||||
}
|
||||
let moduleKind = compilerOptions.module ?? this._ts.ModuleKind.ESNext;
|
||||
let esModuleInterop = compilerOptions.esModuleInterop;
|
||||
if ((0, transpile_module_1.isModernNodeModuleKind)(moduleKind)) {
|
||||
esModuleInterop = true;
|
||||
moduleKind = this._ts.ModuleKind.ESNext;
|
||||
}
|
||||
return {
|
||||
...compilerOptions,
|
||||
module: moduleKind,
|
||||
esModuleInterop,
|
||||
moduleResolution,
|
||||
/**
|
||||
* This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
|
||||
*/
|
||||
customConditions: undefined,
|
||||
};
|
||||
}
|
||||
getCompiledOutput(fileContent, fileName, options) {
|
||||
const isEsmMode = this.configSet.useESM && options.supportsStaticESM;
|
||||
this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
|
||||
if (!this._initialCompilerOptions.isolatedModules && (0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
||||
this._logger.warn("Using hybrid module kind (Node16/18/Next) is only supported in \"isolatedModules: true\". Please set \"isolatedModules: true\" in your tsconfig.json." /* Helps.UsingModernNodeResolution */);
|
||||
}
|
||||
const moduleKind = this._initialCompilerOptions.module;
|
||||
const currentModuleKind = this._compilerOptions.module;
|
||||
if (this._languageService) {
|
||||
if (constants_1.JS_JSX_REGEX.test(fileName) && !this._compilerOptions.allowJs) {
|
||||
this._logger.warn({ fileName: fileName }, (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: fileName }));
|
||||
return {
|
||||
code: fileContent,
|
||||
};
|
||||
}
|
||||
this._logger.debug({ fileName }, 'getCompiledOutput(): compiling using language service');
|
||||
// Must set memory cache before attempting to compile
|
||||
this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
|
||||
const output = this._languageService.getEmitOutput(fileName);
|
||||
const diagnostics = this.getDiagnostics(fileName);
|
||||
if (!isEsmMode && diagnostics.length) {
|
||||
this.configSet.raiseDiagnostics(diagnostics, fileName, this._logger);
|
||||
if (options.watchMode) {
|
||||
this._logger.debug({ fileName }, '_doTypeChecking(): starting watch mode computing diagnostics');
|
||||
for (const entry of options.depGraphs.entries()) {
|
||||
const normalizedModuleNames = entry[1].resolvedModuleNames.map((moduleName) => (0, path_1.normalize)(moduleName));
|
||||
const fileToReTypeCheck = entry[0];
|
||||
if (normalizedModuleNames.includes(fileName) && this.configSet.shouldReportDiagnostics(fileToReTypeCheck)) {
|
||||
this._logger.debug({ fileToReTypeCheck }, '_doTypeChecking(): computing diagnostics using language service');
|
||||
this._updateMemoryCache(this._getFileContentFromCache(fileToReTypeCheck), fileToReTypeCheck);
|
||||
const importedModulesDiagnostics = [
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSemanticDiagnostics(fileToReTypeCheck),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSyntacticDiagnostics(fileToReTypeCheck),
|
||||
];
|
||||
// will raise or just warn diagnostics depending on config
|
||||
this.configSet.raiseDiagnostics(importedModulesDiagnostics, fileName, this._logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output.emitSkipped) {
|
||||
if (constants_1.TS_TSX_REGEX.test(fileName)) {
|
||||
throw new Error((0, messages_1.interpolate)("Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}" /* Errors.CannotProcessFile */, { file: fileName }));
|
||||
}
|
||||
else {
|
||||
this._logger.warn((0, messages_1.interpolate)("Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`" /* Errors.CannotProcessFileReturnOriginal */, { file: fileName }));
|
||||
return {
|
||||
code: fileContent,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Throw an error when requiring `.d.ts` files.
|
||||
if (!output.outputFiles.length) {
|
||||
throw new TypeError((0, messages_1.interpolate)("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`." /* Errors.UnableToRequireDefinitionFile */, {
|
||||
file: (0, path_1.basename)(fileName),
|
||||
}));
|
||||
}
|
||||
const { outputFiles } = output;
|
||||
return this._compilerOptions.sourceMap
|
||||
? {
|
||||
code: (0, compiler_utils_1.updateOutput)(outputFiles[1].text, fileName, outputFiles[0].text),
|
||||
diagnostics,
|
||||
}
|
||||
: {
|
||||
code: (0, compiler_utils_1.updateOutput)(outputFiles[0].text, fileName),
|
||||
diagnostics,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._logger.debug({ fileName }, 'getCompiledOutput(): compiling as isolated module');
|
||||
assertCompilerOptionsWithJestTransformMode(this._initialCompilerOptions, isEsmMode, this._logger);
|
||||
const result = this._transpileOutput(fileContent, fileName);
|
||||
if (result.diagnostics && this.configSet.shouldReportDiagnostics(fileName)) {
|
||||
this.configSet.raiseDiagnostics(result.diagnostics, fileName, this._logger);
|
||||
}
|
||||
return {
|
||||
code: (0, compiler_utils_1.updateOutput)(result.outputText, fileName, result.sourceMapText),
|
||||
};
|
||||
}
|
||||
}
|
||||
_transpileOutput(fileContent, fileName) {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* This code path should be removed in the next major version to benefit from checking on compiler options
|
||||
*/
|
||||
if (!(0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
||||
return this._ts.transpileModule(fileContent, {
|
||||
fileName,
|
||||
transformers: this._makeTransformers(this.configSet.resolvedTransformers),
|
||||
compilerOptions: this._compilerOptions,
|
||||
reportDiagnostics: this.configSet.shouldReportDiagnostics(fileName),
|
||||
});
|
||||
}
|
||||
return (0, transpile_module_1.tsTranspileModule)(fileContent, {
|
||||
fileName,
|
||||
transformers: (program) => {
|
||||
this.program = program;
|
||||
return this._makeTransformers(this.configSet.resolvedTransformers);
|
||||
},
|
||||
compilerOptions: this._initialCompilerOptions,
|
||||
reportDiagnostics: fileName ? this.configSet.shouldReportDiagnostics(fileName) : false,
|
||||
});
|
||||
}
|
||||
_makeTransformers(customTransformers) {
|
||||
return {
|
||||
before: customTransformers.before.map((beforeTransformer) => beforeTransformer.factory(this, beforeTransformer.options)),
|
||||
after: customTransformers.after.map((afterTransformer) => afterTransformer.factory(this, afterTransformer.options)),
|
||||
afterDeclarations: customTransformers.afterDeclarations.map((afterDeclarations) => afterDeclarations.factory(this, afterDeclarations.options)),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_createLanguageService() {
|
||||
// Initialize memory cache for typescript compiler
|
||||
this._parsedTsConfig.fileNames
|
||||
.filter((fileName) => constants_1.TS_TSX_REGEX.test(fileName) && !this.configSet.isTestFile(fileName))
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
.forEach((fileName) => this._fileVersionCache.set(fileName, 0));
|
||||
/* istanbul ignore next */
|
||||
const serviceHost = {
|
||||
useCaseSensitiveFileNames: () => this._ts.sys.useCaseSensitiveFileNames,
|
||||
getProjectVersion: () => String(this._projectVersion),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
getScriptFileNames: () => [...this._fileVersionCache.keys()],
|
||||
getScriptVersion: (fileName) => {
|
||||
const normalizedFileName = (0, path_1.normalize)(fileName);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const version = this._fileVersionCache.get(normalizedFileName);
|
||||
// We need to return `undefined` and not a string here because TypeScript will use
|
||||
// `getScriptVersion` and compare against their own version - which can be `undefined`.
|
||||
// If we don't return `undefined` it results in `undefined === "undefined"` and run
|
||||
// `createProgram` again (which is very slow). Using a `string` assertion here to avoid
|
||||
// TypeScript errors from the function signature (expects `(x: string) => string`).
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return version === undefined ? undefined : String(version);
|
||||
},
|
||||
getScriptSnapshot: (fileName) => {
|
||||
const normalizedFileName = (0, path_1.normalize)(fileName);
|
||||
const hit = this._isFileInCache(normalizedFileName);
|
||||
this._logger.trace({ normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
||||
// Read file content from either memory cache or Jest runtime cache or fallback to file system read
|
||||
if (!hit) {
|
||||
const fileContent =
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.get(normalizedFileName) ??
|
||||
this._runtimeCacheFS.get(normalizedFileName) ??
|
||||
this._cachedReadFile?.(normalizedFileName) ??
|
||||
undefined;
|
||||
if (fileContent !== undefined) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.set(normalizedFileName, fileContent);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(normalizedFileName, 1);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const contents = this._fileContentCache.get(normalizedFileName);
|
||||
if (contents === undefined)
|
||||
return;
|
||||
return this._ts.ScriptSnapshot.fromString(contents);
|
||||
},
|
||||
fileExists: (0, lodash_memoize_1.default)(this._ts.sys.fileExists),
|
||||
readFile: this._cachedReadFile ?? this._ts.sys.readFile,
|
||||
readDirectory: (0, lodash_memoize_1.default)(this._ts.sys.readDirectory),
|
||||
getDirectories: (0, lodash_memoize_1.default)(this._ts.sys.getDirectories),
|
||||
directoryExists: (0, lodash_memoize_1.default)(this._ts.sys.directoryExists),
|
||||
realpath: this._ts.sys.realpath && (0, lodash_memoize_1.default)(this._ts.sys.realpath),
|
||||
getNewLine: () => constants_1.LINE_FEED,
|
||||
getCurrentDirectory: () => this.configSet.cwd,
|
||||
getCompilationSettings: () => this._compilerOptions,
|
||||
getDefaultLibFileName: () => this._ts.getDefaultLibFilePath(this._compilerOptions),
|
||||
getCustomTransformers: () => this._makeTransformers(this.configSet.resolvedTransformers),
|
||||
resolveModuleNames: (moduleNames, containingFile) => moduleNames.map((moduleName) => this._resolveModuleName(moduleName, containingFile).resolvedModule),
|
||||
};
|
||||
this._logger.debug('created language service');
|
||||
this._languageService = this._ts.createLanguageService(serviceHost, this._ts.createDocumentRegistry(this._ts.sys.useCaseSensitiveFileNames, this.configSet.cwd));
|
||||
this.program = this._languageService.getProgram();
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getFileContentFromCache(filePath) {
|
||||
const normalizedFilePath = (0, path_1.normalize)(filePath);
|
||||
let resolvedFileContent = this._runtimeCacheFS.get(normalizedFilePath);
|
||||
if (!resolvedFileContent) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolvedFileContent = this._moduleResolutionHost.readFile(normalizedFilePath);
|
||||
this._runtimeCacheFS.set(normalizedFilePath, resolvedFileContent);
|
||||
}
|
||||
return resolvedFileContent;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getImportedModulePaths(resolvedFileContent, containingFile) {
|
||||
return this._ts
|
||||
.preProcessFile(resolvedFileContent, true, true)
|
||||
.importedFiles.map((importedFile) => {
|
||||
const { resolvedModule } = this._resolveModuleName(importedFile.fileName, containingFile);
|
||||
/* istanbul ignore next already covered */
|
||||
const resolvedFileName = resolvedModule?.resolvedFileName;
|
||||
/* istanbul ignore next already covered */
|
||||
return resolvedFileName && !resolvedModule?.isExternalLibraryImport ? resolvedFileName : '';
|
||||
})
|
||||
.filter((resolveFileName) => !!resolveFileName);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_resolveModuleName(moduleNameToResolve, containingFile) {
|
||||
return this._ts.resolveModuleName(moduleNameToResolve, containingFile, this._compilerOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._moduleResolutionHost,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._moduleResolutionCache);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_isFileInCache(fileName) {
|
||||
return (
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.has(fileName) &&
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.has(fileName) &&
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.get(fileName) !== 0);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_updateMemoryCache(contents, fileName, isModuleKindTheSame = true) {
|
||||
this._logger.debug({ fileName }, 'updateMemoryCache: update memory cache for language service');
|
||||
let shouldIncrementProjectVersion = false;
|
||||
const hit = this._isFileInCache(fileName);
|
||||
if (!hit) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(fileName, 1);
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const prevVersion = this._fileVersionCache.get(fileName);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const previousContents = this._fileContentCache.get(fileName);
|
||||
// Avoid incrementing cache when nothing has changed.
|
||||
if (previousContents !== contents) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(fileName, prevVersion + 1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.set(fileName, contents);
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
/**
|
||||
* When a file is from node_modules or referenced to a referenced project and jest wants to transform it, we need
|
||||
* to make sure that the Program is updated with this information
|
||||
*/
|
||||
if (!this._parsedTsConfig.fileNames.includes(fileName) || !isModuleKindTheSame) {
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
}
|
||||
if (shouldIncrementProjectVersion)
|
||||
this._projectVersion++;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getDiagnostics(fileName) {
|
||||
const diagnostics = [];
|
||||
if (this.configSet.shouldReportDiagnostics(fileName)) {
|
||||
this._logger.debug({ fileName }, '_doTypeChecking(): computing diagnostics using language service');
|
||||
// Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
|
||||
diagnostics.push(
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSemanticDiagnostics(fileName),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSyntacticDiagnostics(fileName));
|
||||
}
|
||||
return diagnostics;
|
||||
}
|
||||
}
|
||||
exports.TsCompiler = TsCompiler;
|
||||
8
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.d.ts
generated
vendored
Normal file
8
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { CompilerInstance, CompiledOutput, StringMap, TsJestCompileOptions } from '../../types';
|
||||
import type { ConfigSet } from '../config/config-set';
|
||||
export declare class TsJestCompiler implements CompilerInstance {
|
||||
private readonly _compilerInstance;
|
||||
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
||||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
||||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
|
||||
}
|
||||
18
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js
generated
vendored
Normal file
18
frontend/node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestCompiler = void 0;
|
||||
const ts_compiler_1 = require("./ts-compiler");
|
||||
class TsJestCompiler {
|
||||
_compilerInstance;
|
||||
constructor(configSet, runtimeCacheFS) {
|
||||
// Later we can add swc/esbuild or other typescript compiler instance here
|
||||
this._compilerInstance = new ts_compiler_1.TsCompiler(configSet, runtimeCacheFS);
|
||||
}
|
||||
getResolvedModules(fileContent, fileName, runtimeCacheFS) {
|
||||
return this._compilerInstance.getResolvedModules(fileContent, fileName, runtimeCacheFS);
|
||||
}
|
||||
getCompiledOutput(fileContent, fileName, options) {
|
||||
return this._compilerInstance.getCompiledOutput(fileContent, fileName, options);
|
||||
}
|
||||
}
|
||||
exports.TsJestCompiler = TsJestCompiler;
|
||||
36
frontend/node_modules/ts-jest/dist/legacy/config/config-set.d.ts
generated
vendored
Normal file
36
frontend/node_modules/ts-jest/dist/legacy/config/config-set.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Logger } from 'bs-logger';
|
||||
import type * as ts from 'typescript';
|
||||
import type { TsConfigCompilerOptionsJson } from '../../config/types';
|
||||
import type { RawCompilerOptions } from '../../raw-compiler-options';
|
||||
import type { TsJestAstTransformer, TsJestTransformOptions, TTypeScript } from '../../types';
|
||||
export declare class ConfigSet {
|
||||
readonly parentLogger?: Logger | undefined;
|
||||
/**
|
||||
* Use by e2e, don't mark as internal
|
||||
*/
|
||||
readonly tsJestDigest: string;
|
||||
readonly logger: Logger;
|
||||
readonly compilerModule: TTypeScript;
|
||||
readonly isolatedModules: boolean;
|
||||
readonly cwd: string;
|
||||
readonly rootDir: string;
|
||||
cacheSuffix: string;
|
||||
tsCacheDir: string | undefined;
|
||||
parsedTsConfig: ts.ParsedCommandLine | Record<string, any>;
|
||||
resolvedTransformers: TsJestAstTransformer;
|
||||
useESM: boolean;
|
||||
constructor(jestConfig: TsJestTransformOptions['config'] | undefined, parentLogger?: Logger | undefined);
|
||||
/**
|
||||
* Load TypeScript configuration. Returns the parsed TypeScript config and any `tsconfig` options specified in ts-jest
|
||||
* Subclasses which extend `ConfigSet` can override the default behavior
|
||||
*/
|
||||
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions | TsConfigCompilerOptionsJson, resolvedConfigFile?: string): Record<string, any>;
|
||||
isTestFile(fileName: string): boolean;
|
||||
shouldStringifyContent(filePath: string): boolean;
|
||||
raiseDiagnostics(diagnostics: ts.Diagnostic[], filePath?: string, logger?: Logger): void;
|
||||
shouldReportDiagnostics(filePath: string): boolean;
|
||||
resolvePath(inputPath: string, { throwIfMissing, nodeResolve }?: {
|
||||
throwIfMissing?: boolean;
|
||||
nodeResolve?: boolean;
|
||||
}): string;
|
||||
}
|
||||
622
frontend/node_modules/ts-jest/dist/legacy/config/config-set.js
generated
vendored
Normal file
622
frontend/node_modules/ts-jest/dist/legacy/config/config-set.js
generated
vendored
Normal file
@@ -0,0 +1,622 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConfigSet = exports.TS_JEST_OUT_DIR = exports.IGNORE_DIAGNOSTIC_CODES = exports.MY_DIGEST = void 0;
|
||||
/**
|
||||
* This is the core of settings and so ts-jest.
|
||||
* Since configuration are used to create a good cache key, everything
|
||||
* depending on it is here. Fast jest relies on correct cache keys
|
||||
* depending on all settings that could affect the generated output.
|
||||
*
|
||||
* The big issue is that jest calls first `getCacheKey()` with stringified
|
||||
* version of the `jest.ProjectConfig`, and then later it calls `process()`
|
||||
* with the complete, object version of it.
|
||||
*/
|
||||
const fs_1 = require("fs");
|
||||
const module_1 = __importDefault(require("module"));
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const jest_util_1 = require("jest-util");
|
||||
const json5_1 = __importDefault(require("json5"));
|
||||
const constants_1 = require("../../constants");
|
||||
const hoistJestTransformer = __importStar(require("../../transformers/hoist-jest"));
|
||||
const utils_1 = require("../../utils");
|
||||
const backports_1 = require("../../utils/backports");
|
||||
const importer_1 = require("../../utils/importer");
|
||||
const messages_1 = require("../../utils/messages");
|
||||
const normalize_slashes_1 = require("../../utils/normalize-slashes");
|
||||
const sha1_1 = require("../../utils/sha1");
|
||||
const ts_error_1 = require("../../utils/ts-error");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.MY_DIGEST = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../../.ts-jest-digest'), 'utf8');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.IGNORE_DIAGNOSTIC_CODES = [
|
||||
6059, // "'rootDir' is expected to contain all source files."
|
||||
18002, // "The 'files' list in config file is empty."
|
||||
18003, // "No inputs were found in config file."
|
||||
];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.TS_JEST_OUT_DIR = '$$ts-jest$$';
|
||||
const normalizeRegex = (pattern) => pattern ? (typeof pattern === 'string' ? pattern : pattern.source) : undefined;
|
||||
const toDiagnosticCode = (code) => code ? parseInt(`${code}`.trim().replace(/^TS/, ''), 10) ?? undefined : undefined;
|
||||
const toDiagnosticCodeList = (items, into = []) => {
|
||||
for (let item of items) {
|
||||
if (typeof item === 'string') {
|
||||
const children = item.trim().split(/\s*,\s*/g);
|
||||
if (children.length > 1) {
|
||||
toDiagnosticCodeList(children, into);
|
||||
continue;
|
||||
}
|
||||
item = children[0];
|
||||
}
|
||||
if (!item)
|
||||
continue;
|
||||
const code = toDiagnosticCode(item);
|
||||
if (code && !into.includes(code))
|
||||
into.push(code);
|
||||
}
|
||||
return into;
|
||||
};
|
||||
const requireFromString = (code, fileName) => {
|
||||
// @ts-expect-error `_nodeModulePaths` is not exposed in typing
|
||||
const paths = module_1.default._nodeModulePaths((0, path_1.dirname)(fileName));
|
||||
const parent = module.parent;
|
||||
const m = new module_1.default(fileName, parent);
|
||||
m.filename = fileName;
|
||||
m.paths = [].concat(paths);
|
||||
// @ts-expect-error `_compile` is not exposed in typing
|
||||
m._compile(code, fileName);
|
||||
const exports = m.exports;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
parent && parent.children && parent.children.splice(parent.children.indexOf(m), 1);
|
||||
return exports;
|
||||
};
|
||||
class ConfigSet {
|
||||
parentLogger;
|
||||
/**
|
||||
* Use by e2e, don't mark as internal
|
||||
*/
|
||||
tsJestDigest = exports.MY_DIGEST;
|
||||
logger;
|
||||
compilerModule;
|
||||
isolatedModules;
|
||||
cwd;
|
||||
rootDir;
|
||||
cacheSuffix;
|
||||
tsCacheDir;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parsedTsConfig;
|
||||
resolvedTransformers = {
|
||||
before: [],
|
||||
after: [],
|
||||
afterDeclarations: [],
|
||||
};
|
||||
useESM = false;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
babelConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
babelJestTransformer;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_jestCfg;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_diagnostics;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_stringifyContentRegExp;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_matchablePatterns;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_matchTestFilePath;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_shouldIgnoreDiagnosticsForFile;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_overriddenCompilerOptions = {
|
||||
inlineSourceMap: false,
|
||||
declaration: false, // we don't want to create declaration files
|
||||
isolatedDeclarations: false, // we don't want to create declaration files
|
||||
noEmit: false, // set to true will make compiler API not emit any compiled results.
|
||||
// else istanbul related will be dropped
|
||||
removeComments: false,
|
||||
// to clear out else it's buggy
|
||||
out: undefined,
|
||||
outFile: undefined,
|
||||
composite: undefined, // see https://github.com/TypeStrong/ts-node/pull/657/files
|
||||
declarationDir: undefined,
|
||||
declarationMap: undefined,
|
||||
emitDeclarationOnly: undefined,
|
||||
sourceRoot: undefined,
|
||||
tsBuildInfoFile: undefined,
|
||||
rewriteRelativeImportExtensions: false,
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
tsconfigFilePath;
|
||||
constructor(jestConfig, parentLogger) {
|
||||
this.parentLogger = parentLogger;
|
||||
this.logger = this.parentLogger
|
||||
? this.parentLogger.child({ [bs_logger_1.LogContexts.namespace]: 'config' })
|
||||
: utils_1.rootLogger.child({ namespace: 'config' });
|
||||
this._backportJestCfg(jestConfig ?? Object.create(null));
|
||||
this.cwd = (0, path_1.normalize)(this._jestCfg.cwd ?? process.cwd());
|
||||
this.rootDir = (0, path_1.normalize)(this._jestCfg.rootDir ?? this.cwd);
|
||||
const tsJestCfg = this._jestCfg.globals && this._jestCfg.globals['ts-jest'];
|
||||
const options = tsJestCfg ?? Object.create(null);
|
||||
// compiler module
|
||||
this.compilerModule = importer_1.importer.typescript("Using \"ts-jest\" requires this package to be installed." /* ImportReasons.TsJest */, options.compiler ?? 'typescript');
|
||||
this.logger.debug({ compilerModule: this.compilerModule }, 'normalized compiler module config via ts-jest option');
|
||||
this._setupConfigSet(options);
|
||||
this._matchablePatterns = [...this._jestCfg.testMatch, ...this._jestCfg.testRegex].filter((pattern) =>
|
||||
/**
|
||||
* jest config testRegex doesn't always deliver the correct RegExp object
|
||||
* See https://github.com/facebook/jest/issues/9778
|
||||
*/
|
||||
pattern instanceof RegExp || typeof pattern === 'string');
|
||||
if (!this._matchablePatterns.length) {
|
||||
this._matchablePatterns.push(...constants_1.DEFAULT_JEST_TEST_MATCH);
|
||||
}
|
||||
this._matchTestFilePath = (0, jest_util_1.globsToMatcher)(this._matchablePatterns.filter((pattern) => typeof pattern === 'string'));
|
||||
// isolatedModules
|
||||
if (options.isolatedModules) {
|
||||
this.parsedTsConfig.options.isolatedModules = true;
|
||||
if (this.tsconfigFilePath) {
|
||||
this.logger.warn((0, messages_1.interpolate)("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\" in {{tsconfigFilePath}} instead, see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithTsconfigPath */, {
|
||||
tsconfigFilePath: this.tsconfigFilePath,
|
||||
}));
|
||||
}
|
||||
else {
|
||||
this.logger.warn("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\", see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithoutTsconfigPath */);
|
||||
}
|
||||
}
|
||||
this.isolatedModules = this.parsedTsConfig.options.isolatedModules ?? false;
|
||||
this._resolveTsCacheDir();
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_backportJestCfg(jestCfg) {
|
||||
const config = (0, backports_1.backportJestConfig)(this.logger, jestCfg);
|
||||
this.logger.debug({ jestConfig: config }, 'normalized jest config');
|
||||
this._jestCfg = {
|
||||
...config,
|
||||
testMatch: config.testMatch ?? constants_1.DEFAULT_JEST_TEST_MATCH,
|
||||
testRegex: config.testRegex ?? [],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_setupConfigSet(options) {
|
||||
// useESM
|
||||
this.useESM = options.useESM ?? false;
|
||||
// babel config (for babel-jest) default is undefined so we don't need to have fallback like tsConfig
|
||||
if (!options.babelConfig) {
|
||||
this.logger.debug('babel is disabled');
|
||||
}
|
||||
else {
|
||||
const baseBabelCfg = { cwd: this.cwd };
|
||||
if (typeof options.babelConfig === 'string') {
|
||||
const babelCfgPath = this.resolvePath(options.babelConfig);
|
||||
const babelFileExtName = (0, path_1.extname)(options.babelConfig);
|
||||
if (babelFileExtName === '.js' || babelFileExtName === '.cjs') {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...require(babelCfgPath),
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...json5_1.default.parse((0, fs_1.readFileSync)(babelCfgPath, 'utf-8')),
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (typeof options.babelConfig === 'object') {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...options.babelConfig,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.babelConfig = baseBabelCfg;
|
||||
}
|
||||
this.logger.debug({ babelConfig: this.babelConfig }, 'normalized babel config via ts-jest option');
|
||||
this.babelJestTransformer = importer_1.importer
|
||||
.babelJest("Using \"babel-jest\" requires this package to be installed." /* ImportReasons.BabelJest */)
|
||||
.createTransformer(this.babelConfig);
|
||||
this.logger.debug('created babel-jest transformer');
|
||||
}
|
||||
// diagnostics
|
||||
const diagnosticsOpt = options.diagnostics ?? true;
|
||||
const ignoreList = [...exports.IGNORE_DIAGNOSTIC_CODES];
|
||||
if (typeof diagnosticsOpt === 'object') {
|
||||
const { ignoreCodes } = diagnosticsOpt;
|
||||
if (ignoreCodes) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
Array.isArray(ignoreCodes) ? ignoreList.push(...ignoreCodes) : ignoreList.push(ignoreCodes);
|
||||
}
|
||||
this._diagnostics = {
|
||||
pretty: diagnosticsOpt.pretty ?? true,
|
||||
exclude: diagnosticsOpt.exclude ?? [],
|
||||
ignoreCodes: toDiagnosticCodeList(ignoreList),
|
||||
throws: !diagnosticsOpt.warnOnly,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._diagnostics = {
|
||||
ignoreCodes: diagnosticsOpt ? toDiagnosticCodeList(ignoreList) : [],
|
||||
exclude: [],
|
||||
pretty: true,
|
||||
throws: diagnosticsOpt,
|
||||
};
|
||||
}
|
||||
if (diagnosticsOpt) {
|
||||
this._shouldIgnoreDiagnosticsForFile = this._diagnostics.exclude.length
|
||||
? (0, jest_util_1.globsToMatcher)(this._diagnostics.exclude)
|
||||
: () => false;
|
||||
}
|
||||
else {
|
||||
this._shouldIgnoreDiagnosticsForFile = () => true;
|
||||
}
|
||||
this.logger.debug({ diagnostics: this._diagnostics }, 'normalized diagnostics config via ts-jest option');
|
||||
// tsconfig
|
||||
const tsconfigOpt = options.tsconfig;
|
||||
const configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined;
|
||||
this.parsedTsConfig = this._getAndResolveTsConfig(typeof tsconfigOpt === 'object' ? tsconfigOpt : undefined, configFilePath);
|
||||
// throw errors if any matching wanted diagnostics
|
||||
this.raiseDiagnostics(this.parsedTsConfig.errors, configFilePath);
|
||||
this.logger.debug({ tsconfig: this.parsedTsConfig }, 'normalized typescript config via ts-jest option');
|
||||
// transformers
|
||||
this.resolvedTransformers.before = [
|
||||
{
|
||||
factory: hoistJestTransformer.factory,
|
||||
name: hoistJestTransformer.name,
|
||||
version: hoistJestTransformer.version,
|
||||
},
|
||||
];
|
||||
const { astTransformers } = options;
|
||||
if (astTransformers) {
|
||||
const resolveTransformerFunc = (transformerPath) => {
|
||||
let transformerFunc;
|
||||
if ((0, path_1.extname)(transformerPath) === '.ts') {
|
||||
const compiledTransformer = importer_1.importer
|
||||
.esBuild("Using \"esbuild\" requires this package to be installed." /* ImportReasons.EsBuild */)
|
||||
.transformSync((0, fs_1.readFileSync)(transformerPath, 'utf-8'), {
|
||||
loader: 'ts',
|
||||
format: 'cjs',
|
||||
target: 'es2015',
|
||||
}).code;
|
||||
transformerFunc = requireFromString(compiledTransformer, transformerPath.replace('.ts', '.js'));
|
||||
}
|
||||
else {
|
||||
transformerFunc = require(transformerPath);
|
||||
}
|
||||
if (!transformerFunc.version) {
|
||||
this.logger.warn("The AST transformer {{file}} must have an `export const version = <your_transformer_version>`" /* Errors.MissingTransformerVersion */, { file: transformerPath });
|
||||
}
|
||||
if (!transformerFunc.name) {
|
||||
this.logger.warn("The AST transformer {{file}} must have an `export const name = <your_transformer_name>`" /* Errors.MissingTransformerName */, { file: transformerPath });
|
||||
}
|
||||
return transformerFunc;
|
||||
};
|
||||
const resolveTransformers = (transformers) => transformers.map((transformer) => {
|
||||
if (typeof transformer === 'string') {
|
||||
return resolveTransformerFunc(this.resolvePath(transformer, { nodeResolve: true }));
|
||||
}
|
||||
else {
|
||||
return {
|
||||
...resolveTransformerFunc(this.resolvePath(transformer.path, { nodeResolve: true })),
|
||||
options: transformer.options,
|
||||
};
|
||||
}
|
||||
});
|
||||
if (astTransformers.before) {
|
||||
/* istanbul ignore next (already covered in unit test) */
|
||||
this.resolvedTransformers.before?.push(...resolveTransformers(astTransformers.before));
|
||||
}
|
||||
if (astTransformers.after) {
|
||||
this.resolvedTransformers = {
|
||||
...this.resolvedTransformers,
|
||||
after: resolveTransformers(astTransformers.after),
|
||||
};
|
||||
}
|
||||
if (astTransformers.afterDeclarations) {
|
||||
this.resolvedTransformers = {
|
||||
...this.resolvedTransformers,
|
||||
afterDeclarations: resolveTransformers(astTransformers.afterDeclarations),
|
||||
};
|
||||
}
|
||||
}
|
||||
this.logger.debug({ customTransformers: this.resolvedTransformers }, 'normalized custom AST transformers via ts-jest option');
|
||||
// stringifyContentPathRegex
|
||||
if (options.stringifyContentPathRegex) {
|
||||
this._stringifyContentRegExp =
|
||||
typeof options.stringifyContentPathRegex === 'string'
|
||||
? new RegExp(normalizeRegex(options.stringifyContentPathRegex)) // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||
: options.stringifyContentPathRegex;
|
||||
this.logger.debug({ stringifyContentPathRegex: this._stringifyContentRegExp }, 'normalized stringifyContentPathRegex config via ts-jest option');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_resolveTsCacheDir() {
|
||||
this.cacheSuffix = (0, sha1_1.sha1)((0, utils_1.stringify)({
|
||||
version: this.compilerModule.version,
|
||||
digest: this.tsJestDigest,
|
||||
babelConfig: this.babelConfig,
|
||||
tsconfig: {
|
||||
options: this.parsedTsConfig.options,
|
||||
raw: this.parsedTsConfig.raw,
|
||||
},
|
||||
isolatedModules: this.isolatedModules,
|
||||
diagnostics: this._diagnostics,
|
||||
transformers: Object.values(this.resolvedTransformers)
|
||||
.reduce((prevVal, currentVal) => [...prevVal, currentVal])
|
||||
.map((transformer) => `${transformer.name}-${transformer.version}`),
|
||||
}));
|
||||
if (!this._jestCfg.cache) {
|
||||
this.logger.debug('file caching disabled');
|
||||
}
|
||||
else {
|
||||
const res = (0, path_1.join)(this._jestCfg.cacheDirectory, 'ts-jest', this.cacheSuffix.substr(0, 2), this.cacheSuffix.substr(2));
|
||||
this.logger.debug({ cacheDirectory: res }, 'will use file caching');
|
||||
this.tsCacheDir = res;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getAndResolveTsConfig(compilerOptions, resolvedConfigFile) {
|
||||
const result = this._resolveTsConfig(compilerOptions, resolvedConfigFile);
|
||||
const { _overriddenCompilerOptions: forcedOptions } = this;
|
||||
const finalOptions = result.options;
|
||||
// Target ES2015 output by default (instead of ES3).
|
||||
if (finalOptions.target === undefined) {
|
||||
finalOptions.target = this.compilerModule.ScriptTarget.ES2015;
|
||||
}
|
||||
// check the module interoperability
|
||||
const target = finalOptions.target;
|
||||
// compute the default if not set
|
||||
const defaultModule = [this.compilerModule.ScriptTarget.ES3, this.compilerModule.ScriptTarget.ES5].includes(target)
|
||||
? this.compilerModule.ModuleKind.CommonJS
|
||||
: this.compilerModule.ModuleKind.ESNext;
|
||||
const moduleValue = finalOptions.module ?? defaultModule;
|
||||
const warningModulesForEsmInterop = [
|
||||
this.compilerModule.ModuleKind.CommonJS,
|
||||
this.compilerModule.ModuleKind.Node16,
|
||||
this.compilerModule.ModuleKind.NodeNext,
|
||||
];
|
||||
if (!this.babelConfig &&
|
||||
!warningModulesForEsmInterop.includes(moduleValue) &&
|
||||
!(finalOptions.esModuleInterop || finalOptions.allowSyntheticDefaultImports)) {
|
||||
result.errors.push({
|
||||
code: messages_1.TsJestDiagnosticCodes.ConfigModuleOption,
|
||||
messageText: "If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information." /* Errors.ConfigNoModuleInterop */,
|
||||
category: this.compilerModule.DiagnosticCategory.Message,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
});
|
||||
}
|
||||
// Make sure when allowJs is enabled, outDir is required to have when using allowJs: true
|
||||
if (finalOptions.allowJs && !finalOptions.outDir) {
|
||||
finalOptions.outDir = exports.TS_JEST_OUT_DIR;
|
||||
}
|
||||
// ensure undefined are removed and other values are overridden
|
||||
for (const key of Object.keys(forcedOptions)) {
|
||||
const val = forcedOptions[key];
|
||||
if (val === undefined) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete finalOptions[key];
|
||||
}
|
||||
else {
|
||||
finalOptions[key] = val;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* See https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
|
||||
* Every time this page is updated, we also need to update here. Here we only show warning message for Node LTS versions
|
||||
*/
|
||||
const nodeJsVer = process.version;
|
||||
const compilationTarget = result.options.target;
|
||||
const TARGET_TO_VERSION_MAPPING = {
|
||||
[this.compilerModule.ScriptTarget.ES2018]: 'es2018',
|
||||
[this.compilerModule.ScriptTarget.ES2019]: 'es2019',
|
||||
[this.compilerModule.ScriptTarget.ES2020]: 'es2020',
|
||||
[this.compilerModule.ScriptTarget.ESNext]: 'ESNext',
|
||||
};
|
||||
/* istanbul ignore next (cover by e2e) */
|
||||
if (compilationTarget &&
|
||||
!this.babelConfig &&
|
||||
nodeJsVer.startsWith('v12') &&
|
||||
compilationTarget > this.compilerModule.ScriptTarget.ES2019) {
|
||||
const message = (0, messages_1.interpolate)("There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping" /* Errors.MismatchNodeTargetMapping */, {
|
||||
nodeJsVer: process.version,
|
||||
compilationTarget: TARGET_TO_VERSION_MAPPING[compilationTarget],
|
||||
});
|
||||
this.logger.warn(message);
|
||||
}
|
||||
const resultOptions = result.options;
|
||||
const sourceMap = resultOptions.sourceMap ?? true;
|
||||
return {
|
||||
...result,
|
||||
options: {
|
||||
...resultOptions,
|
||||
sourceMap,
|
||||
inlineSources: sourceMap,
|
||||
module: resultOptions.module ?? this.compilerModule.ModuleKind.CommonJS,
|
||||
},
|
||||
};
|
||||
}
|
||||
_resolveTsConfig(compilerOptions, resolvedConfigFile) {
|
||||
let config = { compilerOptions: Object.create(null) };
|
||||
let basePath = (0, normalize_slashes_1.normalizeSlashes)(this.rootDir);
|
||||
const ts = this.compilerModule;
|
||||
// Read project configuration when available.
|
||||
this.tsconfigFilePath = resolvedConfigFile
|
||||
? (0, normalize_slashes_1.normalizeSlashes)(resolvedConfigFile)
|
||||
: ts.findConfigFile((0, normalize_slashes_1.normalizeSlashes)(this.rootDir), ts.sys.fileExists);
|
||||
if (this.tsconfigFilePath) {
|
||||
this.logger.debug({ tsConfigFileName: this.tsconfigFilePath }, 'readTsConfig(): reading', this.tsconfigFilePath);
|
||||
const result = ts.readConfigFile(this.tsconfigFilePath, ts.sys.readFile);
|
||||
// Return diagnostics.
|
||||
if (result.error) {
|
||||
return { errors: [result.error], fileNames: [], options: {} };
|
||||
}
|
||||
config = result.config;
|
||||
basePath = (0, normalize_slashes_1.normalizeSlashes)((0, path_1.dirname)(this.tsconfigFilePath));
|
||||
}
|
||||
// Override default configuration options `ts-jest` requires.
|
||||
config.compilerOptions = {
|
||||
...config.compilerOptions,
|
||||
...compilerOptions,
|
||||
};
|
||||
// parse json, merge config extending others, ...
|
||||
return ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, this.tsconfigFilePath);
|
||||
}
|
||||
isTestFile(fileName) {
|
||||
return this._matchablePatterns.some((pattern) => typeof pattern === 'string' ? this._matchTestFilePath(fileName) : pattern.test(fileName));
|
||||
}
|
||||
shouldStringifyContent(filePath) {
|
||||
return this._stringifyContentRegExp ? this._stringifyContentRegExp.test(filePath) : false;
|
||||
}
|
||||
raiseDiagnostics(diagnostics, filePath, logger = this.logger) {
|
||||
const { ignoreCodes } = this._diagnostics;
|
||||
const { DiagnosticCategory } = this.compilerModule;
|
||||
const filteredDiagnostics = filePath && !this.shouldReportDiagnostics(filePath)
|
||||
? []
|
||||
: diagnostics.filter((diagnostic) => {
|
||||
if (diagnostic.file?.fileName && !this.shouldReportDiagnostics(diagnostic.file.fileName)) {
|
||||
return false;
|
||||
}
|
||||
return !ignoreCodes.includes(diagnostic.code);
|
||||
});
|
||||
if (!filteredDiagnostics.length)
|
||||
return;
|
||||
const error = this.createTsError(filteredDiagnostics);
|
||||
// only throw if `warnOnly` and it is a warning or error
|
||||
const importantCategories = [DiagnosticCategory.Warning, DiagnosticCategory.Error];
|
||||
if (this._diagnostics.throws && filteredDiagnostics.some((d) => importantCategories.includes(d.category))) {
|
||||
throw error;
|
||||
}
|
||||
logger.warn({ error }, error.message);
|
||||
}
|
||||
shouldReportDiagnostics(filePath) {
|
||||
const fileExtension = (0, path_1.extname)(filePath);
|
||||
return constants_1.JS_JSX_EXTENSIONS.includes(fileExtension)
|
||||
? this.parsedTsConfig.options.checkJs && !this._shouldIgnoreDiagnosticsForFile(filePath)
|
||||
: !this._shouldIgnoreDiagnosticsForFile(filePath);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
createTsError(diagnostics) {
|
||||
const formatDiagnostics = this._diagnostics.pretty
|
||||
? this.compilerModule.formatDiagnosticsWithColorAndContext
|
||||
: this.compilerModule.formatDiagnostics;
|
||||
/* istanbul ignore next (not possible to cover) */
|
||||
const diagnosticHost = {
|
||||
getNewLine: () => '\n',
|
||||
getCurrentDirectory: () => this.cwd,
|
||||
getCanonicalFileName: (path) => path,
|
||||
};
|
||||
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
|
||||
const diagnosticCodes = diagnostics.map((x) => x.code);
|
||||
return new ts_error_1.TSError(diagnosticText, diagnosticCodes);
|
||||
}
|
||||
resolvePath(inputPath, { throwIfMissing = true, nodeResolve = false } = {}) {
|
||||
let path = inputPath;
|
||||
let nodeResolved = false;
|
||||
if (path.startsWith('<rootDir>')) {
|
||||
path = (0, path_1.resolve)((0, path_1.join)(this.rootDir, path.substr(9)));
|
||||
}
|
||||
else if (!(0, path_1.isAbsolute)(path)) {
|
||||
if (!path.startsWith('.') && nodeResolve) {
|
||||
try {
|
||||
path = require.resolve(path);
|
||||
nodeResolved = true;
|
||||
}
|
||||
catch {
|
||||
this.logger.debug({ path }, 'failed to resolve path', path);
|
||||
}
|
||||
}
|
||||
if (!nodeResolved) {
|
||||
path = (0, path_1.resolve)(this.cwd, path);
|
||||
}
|
||||
}
|
||||
if (!nodeResolved && nodeResolve) {
|
||||
try {
|
||||
path = require.resolve(path);
|
||||
nodeResolved = true;
|
||||
}
|
||||
catch {
|
||||
this.logger.debug({ path }, 'failed to resolve path', path);
|
||||
}
|
||||
}
|
||||
if (throwIfMissing && !(0, fs_1.existsSync)(path)) {
|
||||
throw new Error((0, messages_1.interpolate)("File not found: {{inputPath}} (resolved as: {{resolvedPath}})" /* Errors.FileNotFound */, { inputPath, resolvedPath: path }));
|
||||
}
|
||||
this.logger.debug({ fromPath: inputPath, toPath: path }, 'resolved path from', inputPath, 'to', path);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
exports.ConfigSet = ConfigSet;
|
||||
6
frontend/node_modules/ts-jest/dist/legacy/index.d.ts
generated
vendored
Normal file
6
frontend/node_modules/ts-jest/dist/legacy/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { TsJestTransformerOptions } from '../types';
|
||||
import { TsJestTransformer } from './ts-jest-transformer';
|
||||
declare const _default: {
|
||||
createTransformer: (tsJestConfig?: TsJestTransformerOptions) => TsJestTransformer;
|
||||
};
|
||||
export default _default;
|
||||
6
frontend/node_modules/ts-jest/dist/legacy/index.js
generated
vendored
Normal file
6
frontend/node_modules/ts-jest/dist/legacy/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ts_jest_transformer_1 = require("./ts-jest-transformer");
|
||||
exports.default = {
|
||||
createTransformer: (tsJestConfig) => new ts_jest_transformer_1.TsJestTransformer(tsJestConfig),
|
||||
};
|
||||
28
frontend/node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts
generated
vendored
Normal file
28
frontend/node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { SyncTransformer, TransformedSource } from '@jest/transform';
|
||||
import type { CompilerInstance, TsJestTransformerOptions, TsJestTransformOptions } from '../types';
|
||||
import { ConfigSet } from './config/config-set';
|
||||
export declare class TsJestTransformer implements SyncTransformer<TsJestTransformerOptions> {
|
||||
private readonly transformerOptions?;
|
||||
private readonly _logger;
|
||||
protected _compiler: CompilerInstance;
|
||||
private _transformCfgStr;
|
||||
private _depGraphs;
|
||||
private _watchMode;
|
||||
constructor(transformerOptions?: TsJestTransformerOptions | undefined);
|
||||
private _configsFor;
|
||||
protected _createConfigSet(config: TsJestTransformOptions['config'] | undefined): ConfigSet;
|
||||
protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;
|
||||
process(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): TransformedSource;
|
||||
processAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<TransformedSource>;
|
||||
private processWithTs;
|
||||
private runTsJestHook;
|
||||
/**
|
||||
* Jest uses this to cache the compiled version of a file
|
||||
*
|
||||
* @see https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getCacheKey(fileContent: string, filePath: string, transformOptions: TsJestTransformOptions): string;
|
||||
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<string>;
|
||||
}
|
||||
293
frontend/node_modules/ts-jest/dist/legacy/ts-jest-transformer.js
generated
vendored
Normal file
293
frontend/node_modules/ts-jest/dist/legacy/ts-jest-transformer.js
generated
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const constants_1 = require("../constants");
|
||||
const utils_1 = require("../utils");
|
||||
const importer_1 = require("../utils/importer");
|
||||
const messages_1 = require("../utils/messages");
|
||||
const sha1_1 = require("../utils/sha1");
|
||||
const compiler_1 = require("./compiler");
|
||||
const compiler_utils_1 = require("./compiler/compiler-utils");
|
||||
const config_set_1 = require("./config/config-set");
|
||||
const isNodeModule = (filePath) => {
|
||||
return path_1.default.normalize(filePath).split(path_1.default.sep).includes('node_modules');
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.CACHE_KEY_EL_SEPARATOR = '\x00';
|
||||
class TsJestTransformer {
|
||||
transformerOptions;
|
||||
/**
|
||||
* cache ConfigSet between test runs
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static _cachedConfigSets = [];
|
||||
_logger;
|
||||
_compiler;
|
||||
_transformCfgStr;
|
||||
_depGraphs = new Map();
|
||||
_watchMode = false;
|
||||
constructor(transformerOptions) {
|
||||
this.transformerOptions = transformerOptions;
|
||||
this._logger = utils_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
||||
/**
|
||||
* For some unknown reasons, `this` is undefined in `getCacheKey` and `process`
|
||||
* when running Jest in ESM mode
|
||||
*/
|
||||
this.getCacheKey = this.getCacheKey.bind(this);
|
||||
this.getCacheKeyAsync = this.getCacheKeyAsync.bind(this);
|
||||
this.process = this.process.bind(this);
|
||||
this.processAsync = this.processAsync.bind(this);
|
||||
this._logger.debug('created new transformer');
|
||||
process.env.TS_JEST = '1';
|
||||
}
|
||||
_configsFor(transformOptions) {
|
||||
const { config, cacheFS } = transformOptions;
|
||||
const ccs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.value === config);
|
||||
let configSet;
|
||||
if (ccs) {
|
||||
this._transformCfgStr = ccs.transformerCfgStr;
|
||||
this._compiler = ccs.compiler;
|
||||
this._depGraphs = ccs.depGraphs;
|
||||
this._watchMode = ccs.watchMode;
|
||||
configSet = ccs.configSet;
|
||||
}
|
||||
else {
|
||||
// try to look-it up by stringified version
|
||||
const serializedJestCfg = (0, utils_1.stringify)(config);
|
||||
const serializedCcs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.serialized === serializedJestCfg);
|
||||
if (serializedCcs) {
|
||||
// update the object so that we can find it later
|
||||
// this happens because jest first calls getCacheKey with stringified version of
|
||||
// the config, and then it calls the transformer with the proper object
|
||||
serializedCcs.jestConfig.value = config;
|
||||
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
||||
this._compiler = serializedCcs.compiler;
|
||||
this._depGraphs = serializedCcs.depGraphs;
|
||||
this._watchMode = serializedCcs.watchMode;
|
||||
configSet = serializedCcs.configSet;
|
||||
}
|
||||
else {
|
||||
// create the new record in the index
|
||||
this._logger.info('no matching config-set found, creating a new one');
|
||||
if (config.globals?.['ts-jest']) {
|
||||
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},\nSee more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced" /* Deprecations.GlobalsTsJestConfigOption */);
|
||||
}
|
||||
const jestGlobalsConfig = config.globals ?? {};
|
||||
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {};
|
||||
const migratedConfig = this.transformerOptions
|
||||
? {
|
||||
...config,
|
||||
globals: {
|
||||
...jestGlobalsConfig,
|
||||
'ts-jest': {
|
||||
...tsJestGlobalsConfig,
|
||||
...this.transformerOptions,
|
||||
},
|
||||
},
|
||||
}
|
||||
: config;
|
||||
configSet = this._createConfigSet(migratedConfig);
|
||||
const jest = { ...migratedConfig };
|
||||
// we need to remove some stuff from jest config
|
||||
// this which does not depend on config
|
||||
jest.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
this._transformCfgStr = `${new utils_1.JsonableValue(jest).serialized}${configSet.cacheSuffix}`;
|
||||
this._createCompiler(configSet, cacheFS);
|
||||
this._watchMode = process.argv.includes('--watch');
|
||||
TsJestTransformer._cachedConfigSets.push({
|
||||
jestConfig: new utils_1.JsonableValue(config),
|
||||
configSet,
|
||||
transformerCfgStr: this._transformCfgStr,
|
||||
compiler: this._compiler,
|
||||
depGraphs: this._depGraphs,
|
||||
watchMode: this._watchMode,
|
||||
});
|
||||
}
|
||||
}
|
||||
return configSet;
|
||||
}
|
||||
_createConfigSet(config) {
|
||||
return new config_set_1.ConfigSet(config);
|
||||
}
|
||||
_createCompiler(configSet, cacheFS) {
|
||||
this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
|
||||
}
|
||||
process(sourceText, sourcePath, transformOptions) {
|
||||
this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
let result = {
|
||||
code: this.processWithTs(sourceText, sourcePath, transformOptions).code,
|
||||
};
|
||||
if (babelJest) {
|
||||
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
||||
// do not instrument here, jest will do it anyway afterwards
|
||||
result = babelJest.process(result.code, sourcePath, {
|
||||
...transformOptions,
|
||||
instrument: false,
|
||||
});
|
||||
}
|
||||
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
||||
return result;
|
||||
}
|
||||
async processAsync(sourceText, sourcePath, transformOptions) {
|
||||
this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
let result;
|
||||
const processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
|
||||
result = {
|
||||
code: processWithTsResult.code,
|
||||
};
|
||||
if (processWithTsResult.diagnostics?.length) {
|
||||
throw configs.createTsError(processWithTsResult.diagnostics);
|
||||
}
|
||||
if (babelJest) {
|
||||
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
||||
// do not instrument here, jest will do it anyway afterwards
|
||||
result = await babelJest.processAsync(result.code, sourcePath, {
|
||||
...transformOptions,
|
||||
instrument: false,
|
||||
});
|
||||
}
|
||||
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
||||
return result;
|
||||
}
|
||||
processWithTs(sourceText, sourcePath, transformOptions) {
|
||||
let result;
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
const isDefinitionFile = sourcePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
|
||||
const isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
|
||||
const isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
|
||||
if (shouldStringifyContent) {
|
||||
// handles here what we should simply stringify
|
||||
result = {
|
||||
code: `module.exports=${(0, utils_1.stringify)(sourceText)}`,
|
||||
};
|
||||
}
|
||||
else if (isDefinitionFile) {
|
||||
// do not try to compile declaration files
|
||||
result = {
|
||||
code: '',
|
||||
};
|
||||
}
|
||||
else if (isJsFile || isTsFile) {
|
||||
if (isJsFile && isNodeModule(sourcePath)) {
|
||||
const transpiledResult = typescript_1.default.transpileModule(sourceText, {
|
||||
compilerOptions: {
|
||||
...configs.parsedTsConfig.options,
|
||||
module: transformOptions.supportsStaticESM && transformOptions.transformerConfig.useESM
|
||||
? typescript_1.default.ModuleKind.ESNext
|
||||
: typescript_1.default.ModuleKind.CommonJS,
|
||||
},
|
||||
fileName: sourcePath,
|
||||
});
|
||||
result = {
|
||||
code: (0, compiler_utils_1.updateOutput)(transpiledResult.outputText, sourcePath, transpiledResult.sourceMapText),
|
||||
};
|
||||
}
|
||||
else {
|
||||
// transpile TS code (source maps are included)
|
||||
result = this._compiler.getCompiledOutput(sourceText, sourcePath, {
|
||||
depGraphs: this._depGraphs,
|
||||
supportsStaticESM: transformOptions.supportsStaticESM,
|
||||
watchMode: this._watchMode,
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
// we should not get called for files with other extension than js[x], ts[x] and d.ts,
|
||||
// TypeScript will bail if we try to compile, and if it was to call babel, users can
|
||||
// define the transform value with `babel-jest` for this extension instead
|
||||
const 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 */;
|
||||
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)(message, { path: sourcePath }));
|
||||
result = {
|
||||
code: sourceText,
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
runTsJestHook(sourcePath, sourceText, transformOptions, compiledOutput) {
|
||||
let hooksFile = process.env.TS_JEST_HOOKS;
|
||||
let hooks;
|
||||
/* istanbul ignore next (cover by e2e) */
|
||||
if (hooksFile) {
|
||||
hooksFile = path_1.default.resolve(this._configsFor(transformOptions).cwd, hooksFile);
|
||||
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
||||
}
|
||||
// This is not supposed to be a public API but we keep it as some people use it
|
||||
if (hooks?.afterProcess) {
|
||||
this._logger.debug({ fileName: sourcePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
|
||||
const newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
|
||||
if (newResult) {
|
||||
return newResult;
|
||||
}
|
||||
}
|
||||
return compiledOutput;
|
||||
}
|
||||
/**
|
||||
* Jest uses this to cache the compiled version of a file
|
||||
*
|
||||
* @see https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getCacheKey(fileContent, filePath, transformOptions) {
|
||||
const configs = this._configsFor(transformOptions);
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'computing cache key for', filePath);
|
||||
// we do not instrument, ensure it is false all the time
|
||||
const { supportsStaticESM, instrument = false } = transformOptions;
|
||||
const constructingCacheKeyElements = [
|
||||
this._transformCfgStr,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
configs.rootDir,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
`instrument:${instrument ? 'on' : 'off'}`,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
`supportsStaticESM:${supportsStaticESM ? 'on' : 'off'}`,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
fileContent,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
filePath,
|
||||
];
|
||||
if (!configs.isolatedModules && configs.tsCacheDir) {
|
||||
let resolvedModuleNames;
|
||||
if (this._depGraphs.get(filePath)?.fileContent === fileContent) {
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolvedModuleNames = this._depGraphs
|
||||
.get(filePath)
|
||||
.resolvedModuleNames.filter((moduleName) => (0, fs_1.existsSync)(moduleName));
|
||||
}
|
||||
else {
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from TypeScript API for', filePath);
|
||||
resolvedModuleNames = this._compiler.getResolvedModules(fileContent, filePath, transformOptions.cacheFS);
|
||||
this._depGraphs.set(filePath, {
|
||||
fileContent,
|
||||
resolvedModuleNames,
|
||||
});
|
||||
}
|
||||
resolvedModuleNames.forEach((moduleName) => {
|
||||
constructingCacheKeyElements.push(exports.CACHE_KEY_EL_SEPARATOR, moduleName, exports.CACHE_KEY_EL_SEPARATOR, (0, fs_1.statSync)(moduleName).mtimeMs.toString());
|
||||
});
|
||||
}
|
||||
return (0, sha1_1.sha1)(...constructingCacheKeyElements);
|
||||
}
|
||||
async getCacheKeyAsync(sourceText, sourcePath, transformOptions) {
|
||||
return Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions));
|
||||
}
|
||||
}
|
||||
exports.TsJestTransformer = TsJestTransformer;
|
||||
15
frontend/node_modules/ts-jest/dist/presets/all-presets.d.ts
generated
vendored
Normal file
15
frontend/node_modules/ts-jest/dist/presets/all-presets.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
declare const allPresets: {
|
||||
readonly defaults: import("..").DefaultPreset;
|
||||
readonly defaultsLegacy: import("..").DefaultLegacyPreset;
|
||||
readonly defaultsESM: import("..").DefaultEsmPreset;
|
||||
readonly defaultsESMLegacy: import("..").DefaultEsmLegacyPreset;
|
||||
readonly jsWithTs: import("..").JsWithTsPreset;
|
||||
readonly jsWithTsLegacy: import("..").JsWithTsLegacyPreset;
|
||||
readonly jsWithTsESM: import("..").JsWithTsEsmPreset;
|
||||
readonly jsWithTsESMLegacy: import("..").JsWithTsEsmLegacyPreset;
|
||||
readonly jsWithBabel: import("..").JsWithBabelPreset;
|
||||
readonly jsWithBabelLegacy: import("..").JsWithBabelLegacyPreset;
|
||||
readonly jsWithBabelESM: import("..").JsWithBabelEsmPreset;
|
||||
readonly jsWithBabelESMLegacy: import("..").JsWithBabelEsmLegacyPreset;
|
||||
};
|
||||
export default allPresets;
|
||||
42
frontend/node_modules/ts-jest/dist/presets/all-presets.js
generated
vendored
Normal file
42
frontend/node_modules/ts-jest/dist/presets/all-presets.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const create_jest_preset_1 = require("./create-jest-preset");
|
||||
const allPresets = {
|
||||
get defaults() {
|
||||
return (0, create_jest_preset_1.createDefaultPreset)();
|
||||
},
|
||||
get defaultsLegacy() {
|
||||
return (0, create_jest_preset_1.createDefaultLegacyPreset)();
|
||||
},
|
||||
get defaultsESM() {
|
||||
return (0, create_jest_preset_1.createDefaultEsmPreset)();
|
||||
},
|
||||
get defaultsESMLegacy() {
|
||||
return (0, create_jest_preset_1.createDefaultEsmLegacyPreset)();
|
||||
},
|
||||
get jsWithTs() {
|
||||
return (0, create_jest_preset_1.createJsWithTsPreset)();
|
||||
},
|
||||
get jsWithTsLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithTsLegacyPreset)();
|
||||
},
|
||||
get jsWithTsESM() {
|
||||
return (0, create_jest_preset_1.createJsWithTsEsmPreset)();
|
||||
},
|
||||
get jsWithTsESMLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithTsEsmLegacyPreset)();
|
||||
},
|
||||
get jsWithBabel() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelPreset)();
|
||||
},
|
||||
get jsWithBabelLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelLegacyPreset)();
|
||||
},
|
||||
get jsWithBabelESM() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelEsmPreset)();
|
||||
},
|
||||
get jsWithBabelESMLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelEsmLegacyPreset)();
|
||||
},
|
||||
};
|
||||
exports.default = allPresets;
|
||||
18
frontend/node_modules/ts-jest/dist/presets/create-jest-preset.d.ts
generated
vendored
Normal file
18
frontend/node_modules/ts-jest/dist/presets/create-jest-preset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Config } from '@jest/types';
|
||||
import { DefaultEsmLegacyPreset, DefaultEsmPreset, DefaultEsmTransformOptions, DefaultLegacyPreset, DefaultPreset, DefaultTransformOptions, JsWithBabelEsmLegacyPreset, JsWithBabelEsmPreset, JsWithBabelEsmTransformOptions, JsWithBabelLegacyPreset, JsWithBabelPreset, JsWithBabelTransformerOptions, JsWithTsEsmLegacyPreset, JsWithTsEsmPreset, JsWithTsEsmTransformOptions, JsWithTsLegacyPreset, JsWithTsPreset, JsWithTsTransformOptions, TsJestPresets } from '../types';
|
||||
/**
|
||||
* @deprecated use other functions below instead
|
||||
*/
|
||||
export declare function createJestPreset(legacy?: boolean, allowJs?: boolean, extraOptions?: Config.InitialOptions): TsJestPresets;
|
||||
export declare function createDefaultPreset(tsJestTransformOptions?: DefaultTransformOptions): DefaultPreset;
|
||||
export declare function createDefaultLegacyPreset(tsJestTransformOptions?: DefaultTransformOptions): DefaultLegacyPreset;
|
||||
export declare function createJsWithTsPreset(tsJestTransformOptions?: JsWithTsTransformOptions): JsWithTsPreset;
|
||||
export declare function createJsWithTsLegacyPreset(tsJestTransformOptions?: JsWithTsTransformOptions): JsWithTsLegacyPreset;
|
||||
export declare function createJsWithBabelPreset(tsJestTransformOptions?: JsWithBabelTransformerOptions): JsWithBabelPreset;
|
||||
export declare function createJsWithBabelLegacyPreset(tsJestTransformOptions?: JsWithBabelTransformerOptions): JsWithBabelLegacyPreset;
|
||||
export declare function createDefaultEsmPreset(tsJestTransformOptions?: DefaultEsmTransformOptions): DefaultEsmPreset;
|
||||
export declare function createDefaultEsmLegacyPreset(tsJestTransformOptions?: DefaultEsmTransformOptions): DefaultEsmLegacyPreset;
|
||||
export declare function createJsWithTsEsmPreset(tsJestTransformOptions?: JsWithTsEsmTransformOptions): JsWithTsEsmPreset;
|
||||
export declare function createJsWithTsEsmLegacyPreset(tsJestTransformOptions?: JsWithTsEsmTransformOptions): JsWithTsEsmLegacyPreset;
|
||||
export declare function createJsWithBabelEsmPreset(tsJestTransformOptions?: JsWithBabelEsmTransformOptions): JsWithBabelEsmPreset;
|
||||
export declare function createJsWithBabelEsmLegacyPreset(tsJestTransformOptions?: JsWithBabelEsmTransformOptions): JsWithBabelEsmLegacyPreset;
|
||||
180
frontend/node_modules/ts-jest/dist/presets/create-jest-preset.js
generated
vendored
Normal file
180
frontend/node_modules/ts-jest/dist/presets/create-jest-preset.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createJestPreset = createJestPreset;
|
||||
exports.createDefaultPreset = createDefaultPreset;
|
||||
exports.createDefaultLegacyPreset = createDefaultLegacyPreset;
|
||||
exports.createJsWithTsPreset = createJsWithTsPreset;
|
||||
exports.createJsWithTsLegacyPreset = createJsWithTsLegacyPreset;
|
||||
exports.createJsWithBabelPreset = createJsWithBabelPreset;
|
||||
exports.createJsWithBabelLegacyPreset = createJsWithBabelLegacyPreset;
|
||||
exports.createDefaultEsmPreset = createDefaultEsmPreset;
|
||||
exports.createDefaultEsmLegacyPreset = createDefaultEsmLegacyPreset;
|
||||
exports.createJsWithTsEsmPreset = createJsWithTsEsmPreset;
|
||||
exports.createJsWithTsEsmLegacyPreset = createJsWithTsEsmLegacyPreset;
|
||||
exports.createJsWithBabelEsmPreset = createJsWithBabelEsmPreset;
|
||||
exports.createJsWithBabelEsmLegacyPreset = createJsWithBabelEsmLegacyPreset;
|
||||
const constants_1 = require("../constants");
|
||||
const utils_1 = require("../utils");
|
||||
const logger = utils_1.rootLogger.child({ namespace: 'jest-preset' });
|
||||
/**
|
||||
* @deprecated use other functions below instead
|
||||
*/
|
||||
function createJestPreset(legacy = false, allowJs = false, extraOptions = {}) {
|
||||
logger.debug({ allowJs }, 'creating jest presets', allowJs ? 'handling' : 'not handling', 'JavaScript files');
|
||||
const { extensionsToTreatAsEsm, moduleFileExtensions, testMatch } = extraOptions;
|
||||
const supportESM = extensionsToTreatAsEsm?.length;
|
||||
const tsJestTransformOptions = supportESM ? { useESM: true } : {};
|
||||
return {
|
||||
...(extensionsToTreatAsEsm ? { extensionsToTreatAsEsm } : undefined),
|
||||
...(moduleFileExtensions ? { moduleFileExtensions } : undefined),
|
||||
...(testMatch ? { testMatch } : undefined),
|
||||
transform: {
|
||||
...extraOptions.transform,
|
||||
[allowJs ? (supportESM ? '^.+\\.m?[tj]sx?$' : '^.+\\.[tj]sx?$') : '^.+\\.tsx?$']: legacy
|
||||
? ['ts-jest/legacy', tsJestTransformOptions]
|
||||
: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_JS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_JS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_JS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
556
frontend/node_modules/ts-jest/dist/raw-compiler-options.d.ts
generated
vendored
Normal file
556
frontend/node_modules/ts-jest/dist/raw-compiler-options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* @deprecated This interface will be replaced with {@link TsConfigJson.CompilerOptions} in the next major release.
|
||||
*/
|
||||
export interface RawCompilerOptions {
|
||||
/**
|
||||
* Enable importing files with any extension, provided a declaration file is present.
|
||||
*/
|
||||
allowArbitraryExtensions?: boolean | null;
|
||||
/**
|
||||
* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.
|
||||
*/
|
||||
allowImportingTsExtensions?: boolean | null;
|
||||
/**
|
||||
* No longer supported. In early versions, manually set the text encoding for reading files.
|
||||
*/
|
||||
charset?: string | null;
|
||||
/**
|
||||
* Enable constraints that allow a TypeScript project to be used with project references.
|
||||
*/
|
||||
composite?: boolean | null;
|
||||
/**
|
||||
* Conditions to set in addition to the resolver-specific defaults when resolving imports.
|
||||
*/
|
||||
customConditions?: Array<string | null> | null;
|
||||
/**
|
||||
* Generate .d.ts files from TypeScript and JavaScript files in your project.
|
||||
*/
|
||||
declaration?: boolean | null;
|
||||
/**
|
||||
* Specify the output directory for generated declaration files.
|
||||
*/
|
||||
declarationDir?: string | null;
|
||||
/**
|
||||
* Output compiler performance information after building.
|
||||
*/
|
||||
diagnostics?: boolean | null;
|
||||
/**
|
||||
* Reduce the number of projects loaded automatically by TypeScript.
|
||||
*/
|
||||
disableReferencedProjectLoad?: boolean | null;
|
||||
/**
|
||||
* Enforces using indexed accessors for keys declared using an indexed type
|
||||
*/
|
||||
noPropertyAccessFromIndexSignature?: boolean | null;
|
||||
/**
|
||||
* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
||||
*/
|
||||
emitBOM?: boolean | null;
|
||||
/**
|
||||
* Only output d.ts files and not JavaScript files.
|
||||
*/
|
||||
emitDeclarationOnly?: boolean | null;
|
||||
/**
|
||||
* Differentiate between undefined and not present when type checking
|
||||
*/
|
||||
exactOptionalPropertyTypes?: boolean | null;
|
||||
/**
|
||||
* Enable incremental compilation. Requires TypeScript version 3.4 or later.
|
||||
*/
|
||||
incremental?: boolean | null;
|
||||
/**
|
||||
* Specify the folder for .tsbuildinfo incremental compilation files.
|
||||
*/
|
||||
tsBuildInfoFile?: string | null;
|
||||
/**
|
||||
* Include sourcemap files inside the emitted JavaScript.
|
||||
*/
|
||||
inlineSourceMap?: boolean | null;
|
||||
/**
|
||||
* Include source code in the sourcemaps inside the emitted JavaScript.
|
||||
*/
|
||||
inlineSources?: boolean | null;
|
||||
/**
|
||||
* Specify what JSX code is generated.
|
||||
*/
|
||||
jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
|
||||
/**
|
||||
* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit.
|
||||
*/
|
||||
reactNamespace?: string | null;
|
||||
/**
|
||||
* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'
|
||||
*/
|
||||
jsxFactory?: string | null;
|
||||
/**
|
||||
* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
||||
*/
|
||||
jsxFragmentFactory?: string | null;
|
||||
/**
|
||||
* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx`.
|
||||
*/
|
||||
jsxImportSource?: string | null;
|
||||
/**
|
||||
* Print all of the files read during the compilation.
|
||||
*/
|
||||
listFiles?: boolean | null;
|
||||
/**
|
||||
* Specify the location where debugger should locate map files instead of generated locations.
|
||||
*/
|
||||
mapRoot?: string | null;
|
||||
/**
|
||||
* Specify what module code is generated.
|
||||
*/
|
||||
module?: ('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') & (((('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Specify how TypeScript looks up a file from a given module specifier.
|
||||
*/
|
||||
moduleResolution?: ('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') & (((('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Set the newline character for emitting files.
|
||||
*/
|
||||
newLine?: ('crlf' | 'lf') & (((('crlf' | 'lf') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('crlf' | 'lf') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Disable emitting file from a compilation.
|
||||
*/
|
||||
noEmit?: boolean | null;
|
||||
/**
|
||||
* Disable generating custom helper functions like `__extends` in compiled output.
|
||||
*/
|
||||
noEmitHelpers?: boolean | null;
|
||||
/**
|
||||
* Disable emitting files if any type checking errors are reported.
|
||||
*/
|
||||
noEmitOnError?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for expressions and declarations with an implied `any` type..
|
||||
*/
|
||||
noImplicitAny?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting when `this` is given the type `any`.
|
||||
*/
|
||||
noImplicitThis?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting when a local variables aren't read.
|
||||
*/
|
||||
noUnusedLocals?: boolean | null;
|
||||
/**
|
||||
* Raise an error when a function parameter isn't read
|
||||
*/
|
||||
noUnusedParameters?: boolean | null;
|
||||
/**
|
||||
* Disable including any library files, including the default lib.d.ts.
|
||||
*/
|
||||
noLib?: boolean | null;
|
||||
/**
|
||||
* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.
|
||||
*/
|
||||
noResolve?: boolean | null;
|
||||
/**
|
||||
* Disable strict checking of generic signatures in function types.
|
||||
*/
|
||||
noStrictGenericChecks?: boolean | null;
|
||||
/**
|
||||
* Skip type checking .d.ts files that are included with TypeScript.
|
||||
*/
|
||||
skipDefaultLibCheck?: boolean | null;
|
||||
/**
|
||||
* Skip type checking all .d.ts files.
|
||||
*/
|
||||
skipLibCheck?: boolean | null;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
outFile?: string | null;
|
||||
/**
|
||||
* Specify an output folder for all emitted files.
|
||||
*/
|
||||
outDir?: string | null;
|
||||
/**
|
||||
* Disable erasing `const enum` declarations in generated code.
|
||||
*/
|
||||
preserveConstEnums?: boolean | null;
|
||||
/**
|
||||
* Disable resolving symlinks to their realpath. This correlates to the same flag in node.
|
||||
*/
|
||||
preserveSymlinks?: boolean | null;
|
||||
/**
|
||||
* Preserve unused imported values in the JavaScript output that would otherwise be removed
|
||||
*/
|
||||
preserveValueImports?: boolean | null;
|
||||
/**
|
||||
* Disable wiping the console in watch mode
|
||||
*/
|
||||
preserveWatchOutput?: boolean | null;
|
||||
/**
|
||||
* Enable color and formatting in output to make compiler errors easier to read
|
||||
*/
|
||||
pretty?: boolean | null;
|
||||
/**
|
||||
* Disable emitting comments.
|
||||
*/
|
||||
removeComments?: boolean | null;
|
||||
/**
|
||||
* Specify the root folder within your source files.
|
||||
*/
|
||||
rootDir?: string | null;
|
||||
/**
|
||||
* Ensure that each file can be safely transpiled without relying on other imports.
|
||||
*/
|
||||
isolatedModules?: boolean | null;
|
||||
/**
|
||||
* Create source map files for emitted JavaScript files.
|
||||
*/
|
||||
sourceMap?: boolean | null;
|
||||
/**
|
||||
* Specify the root path for debuggers to find the reference source code.
|
||||
*/
|
||||
sourceRoot?: string | null;
|
||||
/**
|
||||
* Disable reporting of excess property errors during the creation of object literals.
|
||||
*/
|
||||
suppressExcessPropertyErrors?: boolean | null;
|
||||
/**
|
||||
* Suppress `noImplicitAny` errors when indexing objects that lack index signatures.
|
||||
*/
|
||||
suppressImplicitAnyIndexErrors?: boolean | null;
|
||||
/**
|
||||
* Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
|
||||
*/
|
||||
target?: ('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') & (((('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Default catch clause variables as `unknown` instead of `any`.
|
||||
*/
|
||||
useUnknownInCatchVariables?: boolean | null;
|
||||
/**
|
||||
* Watch input files.
|
||||
*/
|
||||
watch?: boolean | null;
|
||||
/**
|
||||
* Specify the polling strategy to use when the system runs out of or doesn't support native file watchers. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
fallbackPolling?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'fixedInterval' | 'priorityInterval' | 'dynamicPriority' | 'fixedChunkSize';
|
||||
/**
|
||||
* Specify the strategy for watching directories under systems that lack recursive file-watching functionality. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
watchDirectory?: 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling' | 'fixedChunkSizePolling';
|
||||
/**
|
||||
* Specify the strategy for watching individual files. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
watchFile?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory' | 'fixedChunkSizePolling';
|
||||
/**
|
||||
* Enable experimental support for TC39 stage 2 draft decorators.
|
||||
*/
|
||||
experimentalDecorators?: boolean | null;
|
||||
/**
|
||||
* Emit design-type metadata for decorated declarations in source files.
|
||||
*/
|
||||
emitDecoratorMetadata?: boolean | null;
|
||||
/**
|
||||
* Disable error reporting for unused labels.
|
||||
*/
|
||||
allowUnusedLabels?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for codepaths that do not explicitly return in a function.
|
||||
*/
|
||||
noImplicitReturns?: boolean | null;
|
||||
/**
|
||||
* Add `undefined` to a type when accessed using an index.
|
||||
*/
|
||||
noUncheckedIndexedAccess?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for fallthrough cases in switch statements.
|
||||
*/
|
||||
noFallthroughCasesInSwitch?: boolean | null;
|
||||
/**
|
||||
* Ensure overriding members in derived classes are marked with an override modifier.
|
||||
*/
|
||||
noImplicitOverride?: boolean | null;
|
||||
/**
|
||||
* Disable error reporting for unreachable code.
|
||||
*/
|
||||
allowUnreachableCode?: boolean | null;
|
||||
/**
|
||||
* Ensure that casing is correct in imports.
|
||||
*/
|
||||
forceConsistentCasingInFileNames?: boolean | null;
|
||||
/**
|
||||
* Emit a v8 CPU profile of the compiler run for debugging.
|
||||
*/
|
||||
generateCpuProfile?: string | null;
|
||||
/**
|
||||
* Specify the base directory to resolve non-relative module names.
|
||||
*/
|
||||
baseUrl?: string | null;
|
||||
/**
|
||||
* Specify a set of entries that re-map imports to additional lookup locations.
|
||||
*/
|
||||
paths?: {
|
||||
[k: string]: Array<string | null> | null;
|
||||
} | null;
|
||||
/**
|
||||
* Specify a list of language service plugins to include.
|
||||
*/
|
||||
plugins?: Array<{
|
||||
/**
|
||||
* Plugin name.
|
||||
*/
|
||||
name?: string | null;
|
||||
[k: string]: unknown;
|
||||
} | null> | null;
|
||||
/**
|
||||
* Allow multiple folders to be treated as one when resolving modules.
|
||||
*/
|
||||
rootDirs?: Array<string | null> | null;
|
||||
/**
|
||||
* Specify multiple folders that act like `./node_modules/@types`.
|
||||
*/
|
||||
typeRoots?: Array<string | null> | null;
|
||||
/**
|
||||
* Specify type package names to be included without being referenced in a source file.
|
||||
*/
|
||||
types?: Array<string | null> | null;
|
||||
/**
|
||||
* Enable tracing of the name resolution process. Requires TypeScript version 2.0 or later.
|
||||
*/
|
||||
traceResolution?: boolean | null;
|
||||
/**
|
||||
* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
|
||||
*/
|
||||
allowJs?: boolean | null;
|
||||
/**
|
||||
* Disable truncating types in error messages.
|
||||
*/
|
||||
noErrorTruncation?: boolean | null;
|
||||
/**
|
||||
* Allow 'import x from y' when a module doesn't have a default export.
|
||||
*/
|
||||
allowSyntheticDefaultImports?: boolean | null;
|
||||
/**
|
||||
* Disable adding 'use strict' directives in emitted JavaScript files.
|
||||
*/
|
||||
noImplicitUseStrict?: boolean | null;
|
||||
/**
|
||||
* Print the names of emitted files after a compilation.
|
||||
*/
|
||||
listEmittedFiles?: boolean | null;
|
||||
/**
|
||||
* Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
|
||||
*/
|
||||
disableSizeLimit?: boolean | null;
|
||||
/**
|
||||
* Specify a set of bundled library declaration files that describe the target runtime environment.
|
||||
*/
|
||||
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.Intl' | '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.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & (((('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.Intl' | '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.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('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.Intl' | '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.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & null))> | null;
|
||||
/**
|
||||
* Specify how TypeScript determine a file as module.
|
||||
*/
|
||||
moduleDetection?: 'auto' | 'legacy' | 'force';
|
||||
/**
|
||||
* When type checking, take into account `null` and `undefined`.
|
||||
*/
|
||||
strictNullChecks?: boolean | null;
|
||||
/**
|
||||
* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`.
|
||||
*/
|
||||
maxNodeModuleJsDepth?: number | null;
|
||||
/**
|
||||
* Allow importing helper functions from tslib once per project, instead of including them per-file.
|
||||
*/
|
||||
importHelpers?: boolean | null;
|
||||
/**
|
||||
* Specify emit/checking behavior for imports that are only used for types.
|
||||
*/
|
||||
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
|
||||
/**
|
||||
* Ensure 'use strict' is always emitted.
|
||||
*/
|
||||
alwaysStrict?: boolean | null;
|
||||
/**
|
||||
* Enable all strict type checking options.
|
||||
*/
|
||||
strict?: boolean | null;
|
||||
/**
|
||||
* Check that the arguments for `bind`, `call`, and `apply` methods match the original function.
|
||||
*/
|
||||
strictBindCallApply?: boolean | null;
|
||||
/**
|
||||
* Emit more compliant, but verbose and less performant JavaScript for iteration.
|
||||
*/
|
||||
downlevelIteration?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting in type-checked JavaScript files.
|
||||
*/
|
||||
checkJs?: boolean | null;
|
||||
/**
|
||||
* When assigning functions, check to ensure parameters and the return values are subtype-compatible.
|
||||
*/
|
||||
strictFunctionTypes?: boolean | null;
|
||||
/**
|
||||
* Check for class properties that are declared but not set in the constructor.
|
||||
*/
|
||||
strictPropertyInitialization?: boolean | null;
|
||||
/**
|
||||
* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
|
||||
*/
|
||||
esModuleInterop?: boolean | null;
|
||||
/**
|
||||
* Allow accessing UMD globals from modules.
|
||||
*/
|
||||
allowUmdGlobalAccess?: boolean | null;
|
||||
/**
|
||||
* Make keyof only return strings instead of string, numbers or symbols. Legacy option.
|
||||
*/
|
||||
keyofStringsOnly?: boolean | null;
|
||||
/**
|
||||
* Emit ECMAScript-standard-compliant class fields.
|
||||
*/
|
||||
useDefineForClassFields?: boolean | null;
|
||||
/**
|
||||
* Create sourcemaps for d.ts files.
|
||||
*/
|
||||
declarationMap?: boolean | null;
|
||||
/**
|
||||
* Enable importing .json files
|
||||
*/
|
||||
resolveJsonModule?: boolean | null;
|
||||
/**
|
||||
* Use the package.json 'exports' field when resolving package imports.
|
||||
*/
|
||||
resolvePackageJsonExports?: boolean | null;
|
||||
/**
|
||||
* Use the package.json 'imports' field when resolving imports.
|
||||
*/
|
||||
resolvePackageJsonImports?: boolean | null;
|
||||
/**
|
||||
* Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
assumeChangesOnlyAffectDirectDependencies?: boolean | null;
|
||||
/**
|
||||
* Output more detailed compiler performance information after building.
|
||||
*/
|
||||
extendedDiagnostics?: boolean | null;
|
||||
/**
|
||||
* Print names of files that are part of the compilation and then stop processing.
|
||||
*/
|
||||
listFilesOnly?: boolean | null;
|
||||
/**
|
||||
* Disable preferring source files instead of declaration files when referencing composite projects
|
||||
*/
|
||||
disableSourceOfProjectReferenceRedirect?: boolean | null;
|
||||
/**
|
||||
* Opt a project out of multi-project reference checking when editing.
|
||||
*/
|
||||
disableSolutionSearching?: boolean | null;
|
||||
/**
|
||||
* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting.
|
||||
*/
|
||||
verbatimModuleSyntax?: boolean | null;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
2
frontend/node_modules/ts-jest/dist/raw-compiler-options.js
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/raw-compiler-options.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
9
frontend/node_modules/ts-jest/dist/transformers/hoist-jest.d.ts
generated
vendored
Normal file
9
frontend/node_modules/ts-jest/dist/transformers/hoist-jest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type _ts from 'typescript';
|
||||
import type { TsCompilerInstance } from '../types';
|
||||
/**
|
||||
* Remember to increase the version whenever transformer's content is changed. This is to inform Jest to not reuse
|
||||
* the previous cache which contains old transformer's content
|
||||
*/
|
||||
export declare const version = 4;
|
||||
export declare const name = "hoist-jest";
|
||||
export declare function factory({ configSet }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|
||||
111
frontend/node_modules/ts-jest/dist/transformers/hoist-jest.js
generated
vendored
Normal file
111
frontend/node_modules/ts-jest/dist/transformers/hoist-jest.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.name = exports.version = void 0;
|
||||
exports.factory = factory;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
/**
|
||||
* Remember to increase the version whenever transformer's content is changed. This is to inform Jest to not reuse
|
||||
* the previous cache which contains old transformer's content
|
||||
*/
|
||||
exports.version = 4;
|
||||
// Used for constructing cache key
|
||||
exports.name = 'hoist-jest';
|
||||
const HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock', 'deepUnmock'];
|
||||
const JEST_GLOBALS_MODULE_NAME = '@jest/globals';
|
||||
const JEST_GLOBAL_NAME = 'jest';
|
||||
function factory({ configSet }) {
|
||||
const logger = configSet.logger.child({ namespace: exports.name });
|
||||
const ts = configSet.compilerModule;
|
||||
const importNamesOfJestObj = [];
|
||||
const isJestGlobalImport = (node) => {
|
||||
return (ts.isImportDeclaration(node) &&
|
||||
ts.isStringLiteral(node.moduleSpecifier) &&
|
||||
node.moduleSpecifier.text === JEST_GLOBALS_MODULE_NAME);
|
||||
};
|
||||
const shouldHoistExpression = (node) => {
|
||||
if (ts.isCallExpression(node) &&
|
||||
ts.isPropertyAccessExpression(node.expression) &&
|
||||
HOIST_METHODS.includes(node.expression.name.text)) {
|
||||
if (importNamesOfJestObj.length) {
|
||||
// @jest/globals is in used
|
||||
return ((ts.isIdentifier(node.expression.expression) &&
|
||||
importNamesOfJestObj.includes(node.expression.expression.text)) ||
|
||||
(ts.isPropertyAccessExpression(node.expression.expression) &&
|
||||
ts.isIdentifier(node.expression.expression.expression) &&
|
||||
importNamesOfJestObj.includes(node.expression.expression.expression.text)) ||
|
||||
shouldHoistExpression(node.expression.expression));
|
||||
}
|
||||
else {
|
||||
// @jest/globals is not in used
|
||||
return ((ts.isIdentifier(node.expression.expression) && node.expression.expression.text === JEST_GLOBAL_NAME) ||
|
||||
shouldHoistExpression(node.expression.expression));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Checks whether given node is a statement that we need to hoist
|
||||
*/
|
||||
const isHoistableStatement = (node) => {
|
||||
return ts.isExpressionStatement(node) && shouldHoistExpression(node.expression);
|
||||
};
|
||||
const canHoistInBlockScope = (node) => !!node.statements.find((stmt) => ts.isVariableStatement(stmt) &&
|
||||
stmt.declarationList.declarations.find((decl) => ts.isIdentifier(decl.name) && decl.name.text !== JEST_GLOBAL_NAME) &&
|
||||
node.statements.find((stmt) => isHoistableStatement(stmt)));
|
||||
/**
|
||||
* Sort statements according to priority
|
||||
* - Import Jest object from `@jest/globals`
|
||||
* - Hoistable methods
|
||||
* - Non-hoistable methods
|
||||
*/
|
||||
const sortStatements = (statements) => {
|
||||
if (statements.length <= 1) {
|
||||
return statements;
|
||||
}
|
||||
return statements.sort((stmtA, stmtB) => isJestGlobalImport(stmtA) ||
|
||||
(isHoistableStatement(stmtA) && !isHoistableStatement(stmtB) && !isJestGlobalImport(stmtB))
|
||||
? -1
|
||||
: 1);
|
||||
};
|
||||
const createVisitor = (ctx, _) => {
|
||||
const visitor = (node) => {
|
||||
const resultNode = ts.visitEachChild(node, visitor, ctx);
|
||||
// Since we use `visitEachChild`, we go upwards tree so all children node elements are checked first
|
||||
if (ts.isBlock(resultNode) && canHoistInBlockScope(resultNode)) {
|
||||
const newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
||||
return ts.factory.updateBlock(resultNode, newNodeArrayStatements);
|
||||
}
|
||||
else {
|
||||
if (ts.isSourceFile(resultNode)) {
|
||||
resultNode.statements.forEach((stmt) => {
|
||||
/**
|
||||
* Gather all possible import names, from different types of import syntax including:
|
||||
* - named import, e.g. `import { jest } from '@jest/globals'`
|
||||
* - aliased named import, e.g. `import {jest as aliasedJest} from '@jest/globals'`
|
||||
* - namespace import, e.g `import * as JestGlobals from '@jest/globals'`
|
||||
*/
|
||||
if (isJestGlobalImport(stmt) &&
|
||||
stmt.importClause?.namedBindings &&
|
||||
(ts.isNamespaceImport(stmt.importClause.namedBindings) ||
|
||||
ts.isNamedImports(stmt.importClause.namedBindings))) {
|
||||
const { namedBindings } = stmt.importClause;
|
||||
const jestImportName = ts.isNamespaceImport(namedBindings)
|
||||
? namedBindings.name.text
|
||||
: namedBindings.elements.find((element) => element.name.text === JEST_GLOBAL_NAME || element.propertyName?.text === JEST_GLOBAL_NAME)?.name.text;
|
||||
if (jestImportName) {
|
||||
importNamesOfJestObj.push(jestImportName);
|
||||
}
|
||||
}
|
||||
});
|
||||
const newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
||||
importNamesOfJestObj.length = 0;
|
||||
return ts.factory.updateSourceFile(resultNode, newNodeArrayStatements, resultNode.isDeclarationFile, resultNode.referencedFiles, resultNode.typeReferenceDirectives, resultNode.hasNoDefaultLib, resultNode.libReferenceDirectives);
|
||||
}
|
||||
return resultNode;
|
||||
}
|
||||
};
|
||||
return visitor;
|
||||
};
|
||||
// returns the transformer factory
|
||||
return (ctx) => logger.wrap({ [bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.debug, call: null }, 'visitSourceFileNode(): hoist jest', (sf) => ts.visitNode(sf, createVisitor(ctx, sf)));
|
||||
}
|
||||
8
frontend/node_modules/ts-jest/dist/transpilers/typescript/transpile-module.d.ts
generated
vendored
Normal file
8
frontend/node_modules/ts-jest/dist/transpilers/typescript/transpile-module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import ts from 'typescript';
|
||||
type ExtendedTranspileOptions = Omit<ts.TranspileOptions, 'transformers'> & {
|
||||
transformers?: (program: ts.Program) => ts.CustomTransformers;
|
||||
};
|
||||
type ExtendedTsTranspileModuleFn = (fileContent: string, transpileOptions: ExtendedTranspileOptions) => ts.TranspileOutput;
|
||||
export declare const isModernNodeModuleKind: (module: ts.ModuleKind | undefined) => boolean;
|
||||
export declare const tsTranspileModule: ExtendedTsTranspileModuleFn;
|
||||
export {};
|
||||
170
frontend/node_modules/ts-jest/dist/transpilers/typescript/transpile-module.js
generated
vendored
Normal file
170
frontend/node_modules/ts-jest/dist/transpilers/typescript/transpile-module.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tsTranspileModule = exports.isModernNodeModuleKind = void 0;
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const messages_1 = require("../../utils/messages");
|
||||
const barebonesLibContent = `/// <reference no-default-lib="true"/>
|
||||
interface Boolean {}
|
||||
interface Function {}
|
||||
interface CallableFunction {}
|
||||
interface NewableFunction {}
|
||||
interface IArguments {}
|
||||
interface Number {}
|
||||
interface Object {}
|
||||
interface RegExp {}
|
||||
interface String {}
|
||||
interface Array<T> { length: number; [n: number]: T; }
|
||||
interface SymbolConstructor {
|
||||
(desc?: string | number): symbol;
|
||||
for(name: string): symbol;
|
||||
readonly toStringTag: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
interface Symbol {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}`;
|
||||
const barebonesLibName = 'lib.d.ts';
|
||||
let barebonesLibSourceFile;
|
||||
const carriageReturnLineFeed = '\r\n';
|
||||
const lineFeed = '\n';
|
||||
function getNewLineCharacter(options) {
|
||||
switch (options.newLine) {
|
||||
case typescript_1.default.NewLineKind.CarriageReturnLineFeed:
|
||||
return carriageReturnLineFeed;
|
||||
case typescript_1.default.NewLineKind.LineFeed:
|
||||
default:
|
||||
return lineFeed;
|
||||
}
|
||||
}
|
||||
const isModernNodeModuleKind = (module) => {
|
||||
return module ? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, typescript_1.default.ModuleKind.NodeNext].includes(module) : false;
|
||||
};
|
||||
exports.isModernNodeModuleKind = isModernNodeModuleKind;
|
||||
const shouldCheckProjectPkgJsonContent = (fileName, moduleKind) => {
|
||||
return fileName.endsWith('package.json') && (0, exports.isModernNodeModuleKind)(moduleKind);
|
||||
};
|
||||
/**
|
||||
* Copy source code of {@link ts.transpileModule} from {@link https://github.com/microsoft/TypeScript/blob/main/src/services/transpile.ts}
|
||||
* with extra modifications:
|
||||
* - Remove generation of declaration files
|
||||
* - Allow using custom AST transformers with the internal created {@link Program}
|
||||
*/
|
||||
const transpileWorker = (input, transpileOptions) => {
|
||||
barebonesLibSourceFile ??= typescript_1.default.createSourceFile(barebonesLibName, barebonesLibContent, {
|
||||
languageVersion: typescript_1.default.ScriptTarget.Latest,
|
||||
});
|
||||
const diagnostics = [];
|
||||
const options = transpileOptions.compilerOptions
|
||||
? // @ts-expect-error internal TypeScript API
|
||||
typescript_1.default.fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics)
|
||||
: {};
|
||||
// mix in default options
|
||||
const defaultOptions = typescript_1.default.getDefaultCompilerOptions();
|
||||
for (const key in defaultOptions) {
|
||||
if (Object.hasOwn(defaultOptions, key) && options[key] === undefined) {
|
||||
options[key] = defaultOptions[key];
|
||||
}
|
||||
}
|
||||
// @ts-expect-error internal TypeScript API
|
||||
for (const option of typescript_1.default.transpileOptionValueCompilerOptions) {
|
||||
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
|
||||
if (options.verbatimModuleSyntax && new Set(['isolatedModules']).has(option.name)) {
|
||||
continue;
|
||||
}
|
||||
options[option.name] = option.transpileOptionValue;
|
||||
}
|
||||
// transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths.
|
||||
options.suppressOutputPathCheck = true;
|
||||
// Filename can be non-ts file.
|
||||
options.allowNonTsExtensions = true;
|
||||
options.declaration = false;
|
||||
options.declarationMap = false;
|
||||
const newLine = getNewLineCharacter(options);
|
||||
// if jsx is specified then treat file as .tsx
|
||||
const inputFileName = transpileOptions.fileName ?? (transpileOptions.compilerOptions?.jsx ? 'module.tsx' : 'module.ts');
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
const compilerHost = {
|
||||
getSourceFile: (fileName) => {
|
||||
// @ts-expect-error internal TypeScript API
|
||||
if (fileName === typescript_1.default.normalizePath(inputFileName)) {
|
||||
return sourceFile;
|
||||
}
|
||||
// @ts-expect-error internal TypeScript API
|
||||
return fileName === typescript_1.default.normalizePath(barebonesLibName) ? barebonesLibSourceFile : undefined;
|
||||
},
|
||||
writeFile: (name, text) => {
|
||||
if (node_path_1.default.extname(name) === '.map') {
|
||||
sourceMapText = text;
|
||||
}
|
||||
else {
|
||||
outputText = text;
|
||||
}
|
||||
},
|
||||
getDefaultLibFileName: () => barebonesLibName,
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
getCurrentDirectory: () => '',
|
||||
getNewLine: () => newLine,
|
||||
fileExists: (fileName) => {
|
||||
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
||||
return typescript_1.default.sys.fileExists(fileName);
|
||||
}
|
||||
return fileName === inputFileName;
|
||||
},
|
||||
readFile: (fileName) => {
|
||||
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
||||
return typescript_1.default.sys.readFile(fileName);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
directoryExists: () => true,
|
||||
getDirectories: () => [],
|
||||
};
|
||||
const sourceFile = typescript_1.default.createSourceFile(inputFileName, input, {
|
||||
languageVersion: options.target ?? typescript_1.default.ScriptTarget.ESNext,
|
||||
impliedNodeFormat: typescript_1.default.getImpliedNodeFormatForFile(inputFileName,
|
||||
/*packageJsonInfoCache*/ undefined, compilerHost, options),
|
||||
// @ts-expect-error internal TypeScript API
|
||||
setExternalModuleIndicator: typescript_1.default.getSetExternalModuleIndicator(options),
|
||||
jsDocParsingMode: transpileOptions.jsDocParsingMode ?? typescript_1.default.JSDocParsingMode.ParseAll,
|
||||
});
|
||||
if (transpileOptions.moduleName) {
|
||||
sourceFile.moduleName = transpileOptions.moduleName;
|
||||
}
|
||||
if (transpileOptions.renamedDependencies) {
|
||||
// @ts-expect-error internal TypeScript API
|
||||
sourceFile.renamedDependencies = new Map(Object.entries(transpileOptions.renamedDependencies));
|
||||
}
|
||||
// Output
|
||||
let outputText;
|
||||
let sourceMapText;
|
||||
const inputs = [inputFileName];
|
||||
const program = typescript_1.default.createProgram(inputs, options, compilerHost);
|
||||
if (transpileOptions.reportDiagnostics) {
|
||||
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile));
|
||||
}
|
||||
diagnostics.push(...program.getOptionsDiagnostics());
|
||||
// Emit
|
||||
const result = program.emit(
|
||||
/*targetSourceFile*/ undefined,
|
||||
/*writeFile*/ undefined,
|
||||
/*cancellationToken*/ undefined,
|
||||
/*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers?.(program));
|
||||
diagnostics.push(...result.diagnostics);
|
||||
if (outputText === undefined) {
|
||||
diagnostics.push({
|
||||
category: typescript_1.default.DiagnosticCategory.Error,
|
||||
code: messages_1.TsJestDiagnosticCodes.Generic,
|
||||
messageText: 'No output generated',
|
||||
file: sourceFile,
|
||||
start: 0,
|
||||
length: 0,
|
||||
});
|
||||
}
|
||||
return { outputText: outputText ?? '', diagnostics, sourceMapText };
|
||||
};
|
||||
exports.tsTranspileModule = transpileWorker;
|
||||
282
frontend/node_modules/ts-jest/dist/types.d.ts
generated
vendored
Normal file
282
frontend/node_modules/ts-jest/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
import type { TransformedSource, TransformOptions } from '@jest/transform';
|
||||
import type { Config } from '@jest/types';
|
||||
import type * as _babel from 'babel__core';
|
||||
import type * as _ts from 'typescript';
|
||||
import type { TsConfigCompilerOptionsJson } from './config/types';
|
||||
import { ESM_JS_TRANSFORM_PATTERN, ESM_TS_JS_TRANSFORM_PATTERN, ESM_TS_TRANSFORM_PATTERN, JS_TRANSFORM_PATTERN, TS_JS_TRANSFORM_PATTERN, TS_TRANSFORM_PATTERN } from './constants';
|
||||
import type { ConfigSet } from './legacy/config/config-set';
|
||||
import type { RawCompilerOptions } from './raw-compiler-options';
|
||||
export type TTypeScript = typeof _ts;
|
||||
/**
|
||||
* Don't mark as internal because it is used in TsJestGlobalOptions which is an exposed type
|
||||
*/
|
||||
export type BabelConfig = _babel.TransformOptions;
|
||||
export interface AstTransformer<T = Record<string, unknown>> {
|
||||
path: string;
|
||||
options?: T;
|
||||
}
|
||||
export interface ConfigCustomTransformer {
|
||||
before?: Array<string | AstTransformer>;
|
||||
after?: Array<string | AstTransformer>;
|
||||
afterDeclarations?: Array<string | AstTransformer>;
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link TsJestTransformerOptions} instead
|
||||
*/
|
||||
export type TsJestGlobalOptions = Config.TransformerConfig[1] & {
|
||||
/**
|
||||
* Compiler options. It can be:
|
||||
* - `true` (or `undefined`, it's the default): use default tsconfig file
|
||||
* - `false`: do NOT use default config file
|
||||
* - `path/to/tsconfig.json`: path to a specific tsconfig file (<rootDir> can be used)
|
||||
* - `{...}`: an object with inline compiler options
|
||||
*
|
||||
* @default `undefined` (the default config file will be used if it exists)
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* {@link RawCompilerOptions} will be replaced with {@link TsConfigCompilerOptionsJson} in the next major release
|
||||
*/
|
||||
tsconfig?: boolean | string | RawCompilerOptions | TsConfigCompilerOptionsJson;
|
||||
/**
|
||||
* @deprecated use {@link TsConfigCompilerOptionsJson.isolatedModules} instead
|
||||
*
|
||||
* Compiles files as isolated modules (disables some features)
|
||||
*
|
||||
* @default `undefined` (disables transpiling files with {@link _ts.transpileModule})
|
||||
*/
|
||||
isolatedModules?: boolean;
|
||||
/**
|
||||
* Compiler to use
|
||||
*
|
||||
* @default `typescript`
|
||||
*/
|
||||
compiler?: 'typescript' | 'ttypescript' | string;
|
||||
/**
|
||||
* Custom transformers (mostly used by jest presets)
|
||||
*/
|
||||
astTransformers?: ConfigCustomTransformer;
|
||||
/**
|
||||
* TS diagnostics - less to be reported if `isolatedModules` is `true`. It can be:
|
||||
* - `true` (or `undefined`, it's the default): show all diagnostics
|
||||
* - `false`: hide diagnostics of all files (kind of useless)
|
||||
* - `{...}`: an inline object with fine grained settings
|
||||
*
|
||||
* @default `undefined`
|
||||
*/
|
||||
diagnostics?: boolean | {
|
||||
/**
|
||||
* Enables colorful and pretty output of errors
|
||||
*
|
||||
* @default `undefined` (enables formatting errors)
|
||||
*/
|
||||
pretty?: boolean;
|
||||
/**
|
||||
* List of TypeScript diagnostic error codes to ignore
|
||||
* [here](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json).
|
||||
*
|
||||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
|
||||
* @default `[6059,18002,18003]`
|
||||
*/
|
||||
ignoreCodes?: number | string | Array<number | string>;
|
||||
/**
|
||||
* If specified, diagnostics of source files which path **matches** will be ignored
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* Logs TypeScript errors to stderr instead of throwing exceptions
|
||||
*
|
||||
* @default `undefined` (TypeScript errors will be thrown as exceptions)
|
||||
*/
|
||||
warnOnly?: boolean;
|
||||
};
|
||||
/**
|
||||
* Babel config. It can be:
|
||||
* - `false` (or `undefined`, it's the default): do NOT use babel
|
||||
* - `true`: use babel using default babelrc file
|
||||
* - `path/to/.babelrc`: path to a babelrc file (<rootDir> can be used)
|
||||
* - `{...}`: an object with inline babel options
|
||||
*
|
||||
* @default `undefined` (not using `Babel`)
|
||||
*/
|
||||
babelConfig?: boolean | string | BabelConfig;
|
||||
/**
|
||||
* Kept for backward compatibility to handle __TRANSFORM_HTML__
|
||||
* Any file which will match this regex will be transpiled as a module
|
||||
* exporting the content of the file as a string
|
||||
*/
|
||||
stringifyContentPathRegex?: string | RegExp;
|
||||
/**
|
||||
* Tell `ts-jest` to transform codes to ESM format. This only works in combination with `jest-runtime` ESM option
|
||||
* `supportsStaticESM` true which is passed into Jest transformer
|
||||
*/
|
||||
useESM?: boolean;
|
||||
};
|
||||
/**
|
||||
* For transformers which extends `ts-jest`
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface ProjectConfigTsJest extends Config.ProjectConfig {
|
||||
globals: GlobalConfigTsJest;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface TransformOptionsTsJest<TransformerConfig = unknown> extends TransformOptions<TransformerConfig> {
|
||||
config: Config.ProjectConfig;
|
||||
}
|
||||
/**
|
||||
* For typings in `jest.config.ts`
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface GlobalConfigTsJest extends Config.ConfigGlobals {
|
||||
'ts-jest'?: TsJestGlobalOptions;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface InitialOptionsTsJest extends Config.InitialOptions {
|
||||
globals?: GlobalConfigTsJest;
|
||||
}
|
||||
export type TsJestTransformerOptions = TsJestGlobalOptions;
|
||||
export type TsJestTransformOptions = TransformOptions<TsJestTransformerOptions>;
|
||||
export interface JestConfigWithTsJest extends Omit<Config.InitialOptions, 'transform'> {
|
||||
transform?: {
|
||||
[regex: string]: 'ts-jest' | 'ts-jest/legacy' | ['ts-jest', TsJestTransformerOptions] | ['ts-jest/legacy', TsJestTransformerOptions];
|
||||
} | Config.InitialOptions['transform'];
|
||||
}
|
||||
export type StringMap = Map<string, string>;
|
||||
export interface DepGraphInfo {
|
||||
fileContent: string;
|
||||
resolvedModuleNames: string[];
|
||||
}
|
||||
export interface TsJestCompileOptions {
|
||||
depGraphs: Map<string, DepGraphInfo>;
|
||||
watchMode: boolean;
|
||||
supportsStaticESM: boolean;
|
||||
}
|
||||
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): CompiledOutput;
|
||||
}
|
||||
export interface TsCompilerInstance extends CompilerInstance {
|
||||
configSet: ConfigSet;
|
||||
program: _ts.Program | undefined;
|
||||
}
|
||||
export interface AstTransformerDesc<T = Record<string, unknown>> {
|
||||
name: string;
|
||||
version: number;
|
||||
factory(tsCompiler: TsCompilerInstance, opts?: T): _ts.TransformerFactory<_ts.SourceFile> | _ts.TransformerFactory<_ts.Bundle | _ts.SourceFile>;
|
||||
options?: T;
|
||||
}
|
||||
export interface TsJestAstTransformer {
|
||||
before: AstTransformerDesc[];
|
||||
after: AstTransformerDesc[];
|
||||
afterDeclarations: AstTransformerDesc[];
|
||||
}
|
||||
/**
|
||||
* @deprecated use other preset types below instead
|
||||
*/
|
||||
export type TsJestPresets = Pick<JestConfigWithTsJest, 'extensionsToTreatAsEsm' | 'moduleFileExtensions' | 'transform' | 'testMatch'>;
|
||||
export type DefaultTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type DefaultPreset = {
|
||||
transform: {
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest', DefaultTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultLegacyPreset = {
|
||||
transform: {
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', DefaultTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type DefaultEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & DefaultEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & DefaultEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithTsPreset = {
|
||||
transform: {
|
||||
[TS_JS_TRANSFORM_PATTERN]: ['ts-jest', JsWithTsTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsLegacyPreset = {
|
||||
transform: {
|
||||
[TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithTsTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithTsEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_JS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & JsWithTsEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & JsWithTsEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelTransformerOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithBabelPreset = {
|
||||
transform: {
|
||||
[JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest', JsWithBabelTransformerOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelLegacyPreset = {
|
||||
transform: {
|
||||
[JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithBabelTransformerOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithBabelEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & JsWithBabelEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & JsWithBabelEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
declare module '@jest/types' {
|
||||
namespace Config {
|
||||
interface ConfigGlobals {
|
||||
/**
|
||||
* strangely `@ts-expect-error` doesn't work in this case when running
|
||||
* `npm run build` vs `npm run pretest`
|
||||
*/
|
||||
'ts-jest'?: TsJestTransformerOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
frontend/node_modules/ts-jest/dist/types.js
generated
vendored
Normal file
3
frontend/node_modules/ts-jest/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const constants_1 = require("./constants");
|
||||
1
frontend/node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
118
frontend/node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
118
frontend/node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.backportTsJestDebugEnvVar = exports.backportJestConfig = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const messages_1 = require("./messages");
|
||||
const context = { [bs_logger_1.LogContexts.namespace]: 'backports' };
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportJestConfig = (logger, config) => {
|
||||
logger.debug({ ...context, config }, 'backporting config');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const { globals = {} } = (config || {});
|
||||
const { 'ts-jest': tsJest = {} } = globals;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const mergeTsJest = {};
|
||||
let hadWarnings = false;
|
||||
const warnConfig = (oldPath, newPath, note) => {
|
||||
hadWarnings = true;
|
||||
logger.warn(context, (0, messages_1.interpolate)(note ? "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead.\n \u21B3 {{note}}" /* Deprecations.ConfigOptionWithNote */ : "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead." /* Deprecations.ConfigOption */, {
|
||||
oldPath,
|
||||
newPath,
|
||||
note,
|
||||
}));
|
||||
};
|
||||
if ('__TS_CONFIG__' in globals) {
|
||||
warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsconfig');
|
||||
if (typeof globals.__TS_CONFIG__ === 'object') {
|
||||
mergeTsJest.tsconfig = globals.__TS_CONFIG__;
|
||||
}
|
||||
delete globals.__TS_CONFIG__;
|
||||
}
|
||||
if ('__TRANSFORM_HTML__' in globals) {
|
||||
warnConfig('globals.__TRANSFORM_HTML__', 'globals.ts-jest.stringifyContentPathRegex');
|
||||
if (globals.__TRANSFORM_HTML__) {
|
||||
mergeTsJest.stringifyContentPathRegex = '\\.html?$';
|
||||
}
|
||||
delete globals.__TRANSFORM_HTML__;
|
||||
}
|
||||
if ('typeCheck' in tsJest) {
|
||||
warnConfig('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules');
|
||||
mergeTsJest.isolatedModules = !tsJest.typeCheck;
|
||||
delete tsJest.typeCheck;
|
||||
}
|
||||
if ('tsConfigFile' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfigFile) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfigFile;
|
||||
}
|
||||
delete tsJest.tsConfigFile;
|
||||
}
|
||||
if ('tsConfig' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfig) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfig;
|
||||
}
|
||||
delete tsJest.tsConfig;
|
||||
}
|
||||
if ('enableTsDiagnostics' in tsJest) {
|
||||
warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics');
|
||||
if (tsJest.enableTsDiagnostics) {
|
||||
mergeTsJest.diagnostics = { warnOnly: true };
|
||||
if (typeof tsJest.enableTsDiagnostics === 'string')
|
||||
mergeTsJest.diagnostics.exclude = [tsJest.enableTsDiagnostics];
|
||||
}
|
||||
else {
|
||||
mergeTsJest.diagnostics = false;
|
||||
}
|
||||
delete tsJest.enableTsDiagnostics;
|
||||
}
|
||||
if ('useBabelrc' in tsJest) {
|
||||
warnConfig('globals.ts-jest.useBabelrc', 'globals.ts-jest.babelConfig', "See `babel-jest` related issue: https://github.com/facebook/jest/issues/3845" /* Deprecations.ConfigOptionUseBabelRcNote */);
|
||||
if (tsJest.useBabelrc != null) {
|
||||
mergeTsJest.babelConfig = tsJest.useBabelrc ? true : {};
|
||||
}
|
||||
delete tsJest.useBabelrc;
|
||||
}
|
||||
if ('skipBabel' in tsJest) {
|
||||
warnConfig('globals.ts-jest.skipBabel', 'globals.ts-jest.babelConfig');
|
||||
if (tsJest.skipBabel === false && !mergeTsJest.babelConfig) {
|
||||
mergeTsJest.babelConfig = true;
|
||||
}
|
||||
delete tsJest.skipBabel;
|
||||
}
|
||||
// if we had some warnings we can inform the user about the CLI tool
|
||||
if (hadWarnings) {
|
||||
logger.warn(context, "Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>." /* Helps.MigrateConfigUsingCLI */);
|
||||
}
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
...config,
|
||||
globals: {
|
||||
...globals,
|
||||
'ts-jest': {
|
||||
...mergeTsJest,
|
||||
...tsJest,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.backportJestConfig = backportJestConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportTsJestDebugEnvVar = (logger) => {
|
||||
if ('TS_JEST_DEBUG' in process.env) {
|
||||
const shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '');
|
||||
delete process.env.TS_JEST_DEBUG;
|
||||
if (shouldLog) {
|
||||
process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn';
|
||||
}
|
||||
logger.warn(context, (0, messages_1.interpolate)("Using env. var \"{{old}}\" is deprecated, use \"{{new}}\" instead." /* Deprecations.EnvVar */, {
|
||||
old: 'TS_JEST_DEBUG',
|
||||
new: 'TS_JEST_LOG',
|
||||
}));
|
||||
}
|
||||
};
|
||||
exports.backportTsJestDebugEnvVar = backportTsJestDebugEnvVar;
|
||||
1
frontend/node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
14
frontend/node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
14
frontend/node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPackageVersion = getPackageVersion;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getPackageVersion(moduleName) {
|
||||
try {
|
||||
return require(`${moduleName}/package.json`).version;
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
146
frontend/node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
146
frontend/node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.importer = exports.Importer = void 0;
|
||||
exports.__requireModule = __requireModule;
|
||||
const logger_1 = require("./logger");
|
||||
const memoize_1 = require("./memoize");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'Importer' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Importer {
|
||||
static get instance() {
|
||||
logger.debug('creating Importer singleton');
|
||||
return new Importer();
|
||||
}
|
||||
babelJest(why) {
|
||||
return this._import(why, 'babel-jest');
|
||||
}
|
||||
babelCore(why) {
|
||||
return this._import(why, '@babel/core');
|
||||
}
|
||||
typescript(why, which) {
|
||||
return this._import(why, which);
|
||||
}
|
||||
esBuild(why) {
|
||||
return this._import(why, 'esbuild');
|
||||
}
|
||||
tryThese(moduleName, ...fallbacks) {
|
||||
let name;
|
||||
let loaded;
|
||||
const tries = [moduleName, ...fallbacks];
|
||||
while ((name = tries.shift()) !== undefined) {
|
||||
const req = requireWrapper(name);
|
||||
// remove exports from what we're going to log
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const contextReq = { ...req };
|
||||
delete contextReq.exports;
|
||||
if (req.exists) {
|
||||
// module exists
|
||||
loaded = req;
|
||||
if (req.error) {
|
||||
logger.error({ requireResult: contextReq }, `failed loading module '${name}'`, req.error.message);
|
||||
}
|
||||
else {
|
||||
logger.debug({ requireResult: contextReq }, 'loaded module', name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// module does not exists in the path
|
||||
logger.debug({ requireResult: contextReq }, `module '${name}' not found`);
|
||||
}
|
||||
}
|
||||
// return the loaded one, could be one that has been loaded, or one which has failed during load
|
||||
// but not one which does not exists
|
||||
return loaded;
|
||||
}
|
||||
tryTheseOr(moduleNames, missingResult, allowLoadError = false) {
|
||||
const args = Array.isArray(moduleNames) ? moduleNames : [moduleNames];
|
||||
const result = this.tryThese(...args);
|
||||
if (!result)
|
||||
return missingResult;
|
||||
if (!result.error)
|
||||
return result.exports;
|
||||
if (allowLoadError)
|
||||
return missingResult;
|
||||
throw result.error;
|
||||
}
|
||||
_import(why, moduleName, { alternatives = [], installTip = moduleName } = {}) {
|
||||
// try to load any of the alternative after trying main one
|
||||
const res = this.tryThese(moduleName, ...alternatives);
|
||||
// if we could load one, return it
|
||||
if (res?.exists) {
|
||||
if (!res.error)
|
||||
return res.exports;
|
||||
// it could not load because of a failure while importing, but it exists
|
||||
throw new Error((0, messages_1.interpolate)("Loading module {{module}} failed with error: {{error}}" /* Errors.LoadingModuleFailed */, { module: res.given, error: res.error.message }));
|
||||
}
|
||||
// if it couldn't load, build a nice error message so the user can fix it by himself
|
||||
const msg = alternatives.length ? "Unable to load any of these modules: {{module}}. {{reason}}. To fix it:\n{{fix}}" /* Errors.UnableToLoadAnyModule */ : "Unable to load the module {{module}}. {{reason}} To fix it:\n{{fix}}" /* Errors.UnableToLoadOneModule */;
|
||||
const loadModule = [moduleName, ...alternatives].map((m) => `"${m}"`).join(', ');
|
||||
if (typeof installTip === 'string') {
|
||||
installTip = [{ module: installTip, label: `install "${installTip}"` }];
|
||||
}
|
||||
const fix = installTip
|
||||
.map((tip) => ` ${installTip.length === 1 ? '↳' : '•'} ${(0, messages_1.interpolate)("{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)" /* Helps.FixMissingModule */, tip)}`)
|
||||
.join('\n');
|
||||
throw new Error((0, messages_1.interpolate)(msg, {
|
||||
module: loadModule,
|
||||
reason: why,
|
||||
fix,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.Importer = Importer;
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)((...args) => args.join(':'))
|
||||
], Importer.prototype, "tryThese", null);
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)()
|
||||
], Importer, "instance", null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.importer = Importer.instance;
|
||||
function requireWrapper(moduleName) {
|
||||
let path;
|
||||
let exists = false;
|
||||
try {
|
||||
path = resolveModule(moduleName);
|
||||
exists = true;
|
||||
}
|
||||
catch (error) {
|
||||
return { error: error, exists, given: moduleName };
|
||||
}
|
||||
const result = { exists, path, given: moduleName };
|
||||
try {
|
||||
result.exports = requireModule(path);
|
||||
}
|
||||
catch {
|
||||
try {
|
||||
result.exports = requireModule(moduleName);
|
||||
}
|
||||
catch (error) {
|
||||
result.error = error;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
let requireModule = (mod) => require(mod);
|
||||
let resolveModule = (mod) => require.resolve(mod, { paths: [process.cwd(), __dirname] });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// so that we can test easier
|
||||
function __requireModule(localRequire, localResolve) {
|
||||
requireModule = localRequire;
|
||||
resolveModule = localResolve;
|
||||
}
|
||||
3
frontend/node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
3
frontend/node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './json';
|
||||
export * from './jsonable-value';
|
||||
export * from './logger';
|
||||
19
frontend/node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
19
frontend/node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./json"), exports);
|
||||
__exportStar(require("./jsonable-value"), exports);
|
||||
__exportStar(require("./logger"), exports);
|
||||
2
frontend/node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function stringify(input: unknown): string;
|
||||
export declare function parse(input: string): any;
|
||||
16
frontend/node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
16
frontend/node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringify = stringify;
|
||||
exports.parse = parse;
|
||||
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
||||
const UNDEFINED = 'undefined';
|
||||
function stringify(input) {
|
||||
return input === undefined ? UNDEFINED : (0, fast_json_stable_stringify_1.default)(input);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function parse(input) {
|
||||
return input === UNDEFINED ? undefined : JSON.parse(input);
|
||||
}
|
||||
10
frontend/node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
10
frontend/node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare class JsonableValue<V = Record<string, any>> {
|
||||
private _serialized;
|
||||
private _value;
|
||||
constructor(value: V);
|
||||
set value(value: V);
|
||||
get value(): V;
|
||||
get serialized(): string;
|
||||
valueOf(): V;
|
||||
toString(): string;
|
||||
}
|
||||
29
frontend/node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
29
frontend/node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JsonableValue = void 0;
|
||||
const json_1 = require("./json");
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
class JsonableValue {
|
||||
_serialized;
|
||||
_value;
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
set value(value) {
|
||||
this._value = value;
|
||||
this._serialized = (0, json_1.stringify)(value);
|
||||
}
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
get serialized() {
|
||||
return this._serialized;
|
||||
}
|
||||
valueOf() {
|
||||
return this._value;
|
||||
}
|
||||
toString() {
|
||||
return this._serialized;
|
||||
}
|
||||
}
|
||||
exports.JsonableValue = JsonableValue;
|
||||
1
frontend/node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare let rootLogger: import("bs-logger").Logger;
|
||||
20
frontend/node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
20
frontend/node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.rootLogger = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const backports_1 = require("./backports");
|
||||
const original = process.env.TS_JEST_LOG;
|
||||
const buildOptions = () => ({
|
||||
context: {
|
||||
[bs_logger_1.LogContexts.package]: 'ts-jest',
|
||||
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
||||
version: require('../../package.json').version,
|
||||
},
|
||||
targets: process.env.TS_JEST_LOG ?? undefined,
|
||||
});
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
(0, backports_1.backportTsJestDebugEnvVar)(exports.rootLogger);
|
||||
// re-create the logger if the env var has been backported
|
||||
if (original !== process.env.TS_JEST_LOG) {
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
60
frontend/node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
60
frontend/node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Memoize = Memoize;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cacheProp = Symbol.for('[memoize]');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function Memoize(keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (_, propertyKey, descriptor) => {
|
||||
if (descriptor.value != null) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
|
||||
}
|
||||
else if (descriptor.get != null) {
|
||||
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
|
||||
}
|
||||
};
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureCache(target, reset = false) {
|
||||
if (reset || !target[cacheProp]) {
|
||||
Object.defineProperty(target, cacheProp, {
|
||||
value: Object.create(null),
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
return target[cacheProp];
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureChildCache(target, key, reset = false) {
|
||||
const dict = ensureCache(target);
|
||||
if (reset || !dict[key]) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
dict[key] = new Map();
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return dict[key];
|
||||
}
|
||||
function memoize(namespace,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
func,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return function (...args) {
|
||||
const cache = ensureChildCache(this, namespace);
|
||||
const key = keyBuilder.apply(this, args);
|
||||
if (cache.has(key))
|
||||
return cache.get(key);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = func.apply(this, args);
|
||||
cache.set(key, res);
|
||||
return res;
|
||||
};
|
||||
}
|
||||
4
frontend/node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
4
frontend/node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const TsJestDiagnosticCodes: {
|
||||
readonly Generic: 151000;
|
||||
readonly ConfigModuleOption: 151001;
|
||||
};
|
||||
16
frontend/node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
16
frontend/node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestDiagnosticCodes = void 0;
|
||||
exports.interpolate = interpolate;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function interpolate(msg, vars = {}) {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _));
|
||||
}
|
||||
exports.TsJestDiagnosticCodes = {
|
||||
Generic: 151000,
|
||||
ConfigModuleOption: 151001,
|
||||
};
|
||||
1
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
9
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
9
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeSlashes = normalizeSlashes;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function normalizeSlashes(value) {
|
||||
return value.replace(/\\/g, '/');
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
38
frontend/node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
38
frontend/node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cache = void 0;
|
||||
exports.sha1 = sha1;
|
||||
const crypto_1 = require("crypto");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// stores hashes made out of only one argument being a string
|
||||
exports.cache = Object.create(null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function sha1(...data) {
|
||||
const canCache = data.length === 1 && typeof data[0] === 'string';
|
||||
// caching
|
||||
let cacheKey;
|
||||
if (canCache) {
|
||||
cacheKey = data[0];
|
||||
if (cacheKey in exports.cache) {
|
||||
return exports.cache[cacheKey];
|
||||
}
|
||||
}
|
||||
// we use SHA1 because it's the fastest provided by node
|
||||
// and we are not concerned about security here
|
||||
const hash = (0, crypto_1.createHash)('sha1');
|
||||
data.forEach((item) => {
|
||||
if (typeof item === 'string')
|
||||
hash.update(item, 'utf8');
|
||||
else
|
||||
hash.update(item);
|
||||
});
|
||||
const res = hash.digest('hex').toString();
|
||||
if (canCache) {
|
||||
exports.cache[cacheKey] = res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
37
frontend/node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
37
frontend/node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TSError = exports.INSPECT_CUSTOM = void 0;
|
||||
const util_1 = require("util");
|
||||
const make_error_1 = require("make-error");
|
||||
const logger_1 = require("./logger");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'TSError' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
|
||||
/**
|
||||
* TypeScript diagnostics error.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TSError extends make_error_1.BaseError {
|
||||
diagnosticText;
|
||||
diagnosticCodes;
|
||||
name = 'TSError';
|
||||
constructor(diagnosticText, diagnosticCodes) {
|
||||
super((0, messages_1.interpolate)("{{diagnostics}}" /* Errors.UnableToCompileTypeScript */, {
|
||||
diagnostics: diagnosticText.trim(),
|
||||
}));
|
||||
this.diagnosticText = diagnosticText;
|
||||
this.diagnosticCodes = diagnosticCodes;
|
||||
logger.debug({ diagnosticCodes, diagnosticText }, 'created new TSError');
|
||||
// ensure we blacklist any of our code
|
||||
Object.defineProperty(this, 'stack', { value: '' });
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
[exports.INSPECT_CUSTOM]() {
|
||||
return this.diagnosticText;
|
||||
}
|
||||
}
|
||||
exports.TSError = TSError;
|
||||
Reference in New Issue
Block a user