Skip to content

Commit ba82a9e

Browse files
committed
fix: jest 25 type definitions
A lot of the Jest typings were moved into the core repo rather than the `@types/jest` definitions. See DefinitelyTyped/DefinitelyTyped@ef7406a
1 parent 095b9ba commit ba82a9e

17 files changed

Lines changed: 64 additions & 38 deletions

e2e/__helpers__/test-case/processed-file-io.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { TransformOptions, TransformedSource } from '@jest/transform/build/types'
2+
import { Config } from '@jest/types'
3+
14
import ProcessedSource from '../../../src/__helpers__/processed-source'
25

36
// tslint:disable-next-line:no-default-export
47
export default class ProcessedFileIo extends ProcessedSource {
58
constructor(
69
cwd: string,
710
filename: string,
8-
readonly input: [string, jest.Path, jest.ProjectConfig, jest.TransformOptions],
9-
output: string | jest.TransformedSource,
11+
readonly input: [string, Config.Path, Config.ProjectConfig, TransformOptions],
12+
output: string | TransformedSource,
1013
) {
1114
super(typeof output === 'string' ? output : output.code, filename, cwd)
1215
}

e2e/__helpers__/test-case/run-result.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Config } from '@jest/types'
12
import { LogMessage } from 'bs-logger'
23
import { SpawnSyncReturns } from 'child_process'
34
import { readFileSync, realpathSync } from 'fs'
@@ -19,7 +20,7 @@ export default class RunResult {
1920
cmd: string
2021
args: string[]
2122
env: { [key: string]: string }
22-
config: jest.InitialOptions
23+
config: Config.InitialOptions
2324
digest: string
2425
}>,
2526
) {}

e2e/__helpers__/test-case/runtime.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Config } from '@jest/types'
12
import { sync as spawnSync } from 'cross-spawn'
23
import { createHash } from 'crypto'
34
import stringifyJson = require('fast-json-stable-stringify')
@@ -64,10 +65,10 @@ export function run(name: string, options: RunTestOptions = {}): RunResult {
6465
const jestConfigPath = (path: string = dir) => resolve(path, configFile)
6566

6667
// grab base configuration
67-
let baseConfig: jest.InitialOptions = require(jestConfigPath())
68+
let baseConfig: Config.InitialOptions = require(jestConfigPath())
6869
if (configFile === 'package.json') baseConfig = (baseConfig as any).jest
6970

70-
const extraConfig = {} as jest.InitialOptions
71+
const extraConfig = {} as Config.InitialOptions
7172

7273
let shortCmd: string
7374
let cmdArgs: string[] = []

e2e/__helpers__/test-case/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Config } from '@jest/types'
2+
13
import { TsJestConfig } from '../../../src/types'
24

35
import RunResult from './run-result'
@@ -7,7 +9,7 @@ export interface RunTestOptions {
79
env?: {}
810
inject?: (() => any) | string
911
writeIo?: boolean
10-
jestConfig?: jest.ProjectConfig | any
12+
jestConfig?: Config.ProjectConfig | any
1113
tsJestConfig?: TsJestConfig | any
1214
noCache?: boolean
1315
jestConfigPath?: string

package-lock.json

Lines changed: 7 additions & 4 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
@@ -82,11 +82,13 @@
8282
"devDependencies": {
8383
"@commitlint/cli": "8.x",
8484
"@commitlint/config-conventional": "7.x",
85+
"@jest/transform": "25.x",
86+
"@jest/types": "25.x",
8587
"@types/babel__core": "7.x",
8688
"@types/buffer-from": "latest",
8789
"@types/cross-spawn": "latest",
8890
"@types/fs-extra": "latest",
89-
"@types/jest": "23.x",
91+
"@types/jest": "25.x",
9092
"@types/js-yaml": "latest",
9193
"@types/json5": "latest",
9294
"@types/lodash.memoize": "4.x",

src/__helpers__/fakers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Config } from '@jest/types'
12
import { resolve } from 'path'
23

34
import { BabelConfig, TsJestConfig, TsJestGlobalOptions } from '../types'
@@ -67,8 +68,8 @@ export function tsJestConfig(options?: Partial<TsJestConfig>): TsJestConfig {
6768
}
6869
}
6970

70-
export function jestConfig<T extends jest.ProjectConfig>(
71-
options?: Partial<jest.InitialOptions | jest.ProjectConfig>,
71+
export function jestConfig<T extends Config.ProjectConfig>(
72+
options?: Partial<Config.InitialOptions | Config.ProjectConfig>,
7273
tsJestOptions?: TsJestGlobalOptions,
7374
): T {
7475
const res = {

src/cli/config/migrate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Config } from '@jest/types'
12
import { createLogger } from 'bs-logger'
23
import * as stringifyJson from 'fast-json-stable-stringify'
34
import { existsSync } from 'fs'
@@ -25,7 +26,7 @@ export const run: CliCommand = async (args: Arguments /*, logger: Logger*/) => {
2526
if (!/\.(js|json)$/.test(name)) {
2627
throw new TypeError(`Configuration file ${file} must be a JavaScript or JSON file.`)
2728
}
28-
let actualConfig: jest.InitialOptions = require(filePath)
29+
let actualConfig: Config.InitialOptions = require(filePath)
2930
if (isPackage) {
3031
actualConfig = (actualConfig as any).jest
3132
}
@@ -173,7 +174,7 @@ ${footNotes.join('\n')}
173174
}
174175
}
175176

176-
function cleanupConfig(config: jest.InitialOptions): void {
177+
function cleanupConfig(config: Config.InitialOptions): void {
177178
if (config.globals) {
178179
if ((config as any).globals['ts-jest'] && Object.keys((config as any).globals['ts-jest']).length === 0) {
179180
delete (config as any).globals['ts-jest']

src/compiler.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// tslint:disable:max-line-length
2+
import { Config } from '@jest/types'
23
import { LogLevels } from 'bs-logger'
34
import { removeSync, writeFileSync } from 'fs-extra'
45

@@ -18,7 +19,7 @@ function makeCompiler({
1819
tsJestConfig,
1920
parentConfig,
2021
}: {
21-
jestConfig?: Partial<jest.ProjectConfig>
22+
jestConfig?: Partial<Config.ProjectConfig>
2223
tsJestConfig?: TsJestGlobalOptions
2324
parentConfig?: TsJestGlobalOptions
2425
} = {}) {

src/config/config-set.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Transformer } from '@jest/transform/build/types'
2+
import { Config } from '@jest/types'
13
import { testing } from 'bs-logger'
24
import { resolve } from 'path'
35
import { Diagnostic, DiagnosticCategory, ModuleKind, ParsedCommandLine, ScriptTarget } from 'typescript'
@@ -35,7 +37,7 @@ function createConfigSet({
3537
resolve = defaultResolve,
3638
...others
3739
}: {
38-
jestConfig?: jest.ProjectConfig
40+
jestConfig?: Config.ProjectConfig
3941
tsJestConfig?: TsJestGlobalOptions
4042
parentConfig?: TsJestGlobalOptions
4143
resolve?: ((path: string) => string) | null
@@ -543,7 +545,7 @@ describe('babelJestTransformer', () => {
543545
let cs = createConfigSet({ tsJestConfig: { tsConfig: false } as any })
544546
expect(cs.babelJestTransformer).toBeUndefined()
545547
cs = createConfigSet({ tsJestConfig: { tsConfig: false, babelConfig: {} } as any })
546-
const babelJest = cs.babelJestTransformer as jest.Transformer
548+
const babelJest = cs.babelJestTransformer as Transformer
547549
expect(babelJest.canInstrument).toBe(true)
548550
expect(babelJest.createTransformer).toBeUndefined()
549551
expect(typeof babelJest.getCacheKey).toBe('function')

0 commit comments

Comments
 (0)