Skip to content

Commit 7cebc62

Browse files
committed
fix(typings): set correct typing for tsconfig/tsConfig
1 parent c427fea commit 7cebc62

8 files changed

Lines changed: 17420 additions & 69 deletions

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ docs/
88
presets/index.d.ts
99
*.config.js
1010
.eslintrc.js
11+
src/tsconfig-raw.d.ts

package-lock.json

Lines changed: 16188 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"description": "A preprocessor with source maps support to help use TypeScript with Jest",
1010
"scripts": {
11-
"prebuild": "node scripts/clean-dist.js",
11+
"prebuild": "node scripts/pre-build.js",
1212
"build": "tsc -p tsconfig.build.json",
1313
"postbuild": "node scripts/post-build.js",
1414
"clean": "node scripts/clean.js",
@@ -114,7 +114,9 @@
114114
"husky": "4.x",
115115
"jest": "26.x",
116116
"js-yaml": "latest",
117+
"json-schema-to-typescript": "^10.1.3",
117118
"lint-staged": "latest",
119+
"node-fetch": "^2.6.1",
118120
"npm-run-all": "latest",
119121
"prettier": "2.x",
120122
"source-map": "latest",

scripts/clean-dist.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/pre-build.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs')
4+
const { removeSync } = require('fs-extra')
5+
const { compile } = require('json-schema-to-typescript')
6+
const fetch = require('node-fetch')
7+
const path = require('path')
8+
9+
const Paths = require('./lib/paths')
10+
11+
const tsconfigRawPath = path.join(process.cwd(), 'src', 'tsconfig-raw.d.ts')
12+
removeSync(Paths.distDir)
13+
removeSync(tsconfigRawPath)
14+
15+
void (async () => {
16+
const response = await fetch('https://json.schemastore.org/tsconfig')
17+
const tsconfigSchema = await response.json()
18+
const rawTsconfig = await compile(tsconfigSchema)
19+
fs.writeFileSync(tsconfigRawPath, rawTsconfig)
20+
})()

src/config/config-set.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
AstTransformer,
3232
BabelConfig,
3333
BabelJestTransformer,
34+
RawCompilerOptions,
3435
TsCompiler,
3536
TsJestDiagnosticsCfg,
3637
TsJestGlobalOptions,
@@ -423,9 +424,9 @@ export class ConfigSet {
423424
* Load TypeScript configuration. Returns the parsed TypeScript config and
424425
* any `tsConfig` options specified in ts-jest tsConfig
425426
*/
426-
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): Record<string, any>
427+
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): Record<string, any>
427428
// eslint-disable-next-line no-dupe-class-members
428-
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): ParsedCommandLine {
429+
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): ParsedCommandLine {
429430
let config = { compilerOptions: Object.create(null) }
430431
let basePath = normalizeSlashes(this.rootDir)
431432
const ts = this.compilerModule

0 commit comments

Comments
 (0)