Skip to content

Commit

Permalink
fix(typings): set correct typing for tsconfig/tsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Feb 18, 2021
1 parent c427fea commit 7cebc62
Show file tree
Hide file tree
Showing 8 changed files with 17,420 additions and 69 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs/
presets/index.d.ts
*.config.js
.eslintrc.js
src/tsconfig-raw.d.ts
16,245 changes: 16,188 additions & 57 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"description": "A preprocessor with source maps support to help use TypeScript with Jest",
"scripts": {
"prebuild": "node scripts/clean-dist.js",
"prebuild": "node scripts/pre-build.js",
"build": "tsc -p tsconfig.build.json",
"postbuild": "node scripts/post-build.js",
"clean": "node scripts/clean.js",
Expand Down Expand Up @@ -114,7 +114,9 @@
"husky": "4.x",
"jest": "26.x",
"js-yaml": "latest",
"json-schema-to-typescript": "^10.1.3",
"lint-staged": "latest",
"node-fetch": "^2.6.1",
"npm-run-all": "latest",
"prettier": "2.x",
"source-map": "latest",
Expand Down
7 changes: 0 additions & 7 deletions scripts/clean-dist.js

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/pre-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const fs = require('fs')
const { removeSync } = require('fs-extra')
const { compile } = require('json-schema-to-typescript')
const fetch = require('node-fetch')
const path = require('path')

const Paths = require('./lib/paths')

const tsconfigRawPath = path.join(process.cwd(), 'src', 'tsconfig-raw.d.ts')
removeSync(Paths.distDir)
removeSync(tsconfigRawPath)

void (async () => {
const response = await fetch('https://json.schemastore.org/tsconfig')
const tsconfigSchema = await response.json()
const rawTsconfig = await compile(tsconfigSchema)
fs.writeFileSync(tsconfigRawPath, rawTsconfig)
})()
5 changes: 3 additions & 2 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type {
AstTransformer,
BabelConfig,
BabelJestTransformer,
RawCompilerOptions,
TsCompiler,
TsJestDiagnosticsCfg,
TsJestGlobalOptions,
Expand Down Expand Up @@ -423,9 +424,9 @@ export class ConfigSet {
* Load TypeScript configuration. Returns the parsed TypeScript config and
* any `tsConfig` options specified in ts-jest tsConfig
*/
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): Record<string, any>
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): Record<string, any>
// eslint-disable-next-line no-dupe-class-members
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): ParsedCommandLine {
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): ParsedCommandLine {
let config = { compilerOptions: Object.create(null) }
let basePath = normalizeSlashes(this.rootDir)
const ts = this.compilerModule
Expand Down
Loading

0 comments on commit 7cebc62

Please sign in to comment.