Skip to content

Commit

Permalink
chore: upgrade dependencies, correct typings (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl authored Apr 13, 2020
1 parent 19c32a2 commit b3c55d6
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 104 deletions.
119 changes: 36 additions & 83 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"devDependencies": {
"@commitlint/cli": "8.x",
"@commitlint/config-conventional": "7.x",
"@commitlint/config-conventional": "8.x",
"@jest/transform": "25.x",
"@jest/types": "25.x",
"@types/babel__core": "7.x",
Expand Down
2 changes: 1 addition & 1 deletion src/__helpers__/fakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function makeCompiler({
jestConfig = {
...jestConfig,
testMatch: ['^.+\\.tsx?$'],
testRegex: jestConfig?.testRegex ? testRegex.concat(jestConfig.testRegex) : testRegex,
testRegex: jestConfig?.testRegex ? [...testRegex, ...jestConfig.testRegex] : testRegex,
}
const cs = new ConfigSet(getJestConfig(jestConfig, tsJestConfig), parentConfig)

Expand Down
8 changes: 4 additions & 4 deletions src/cli/config/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Config } from '@jest/types'
import { createLogger } from 'bs-logger'
import * as stringifyJson from 'fast-json-stable-stringify'
import stableStringify = require('fast-json-stable-stringify')
import { existsSync } from 'fs'
import { stringify as stringifyJson5 } from 'json5'
import { basename, resolve } from 'path'
Expand Down Expand Up @@ -119,16 +119,16 @@ Visit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more inf
if (
preset &&
migratedConfig.transform &&
stringifyJson(migratedConfig.transform) === stringifyJson(preset.value.transform)
stableStringify(migratedConfig.transform) === stableStringify(preset.value.transform)
) {
delete migratedConfig.transform
}

// cleanup
cleanupConfig(actualConfig)
cleanupConfig(migratedConfig)
const before = stringifyJson(actualConfig)
const after = stringifyJson(migratedConfig)
const before = stableStringify(actualConfig)
const after = stableStringify(migratedConfig)
if (after === before) {
process.stderr.write(`
No migration needed for given Jest configuration
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compiler-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function cacheResolvedModules(
}
}

export function isTestFile(testMatchPatterns: [string, RegExp], fileName: string) {
export function isTestFile(testMatchPatterns: (string | RegExp)[], fileName: string) {
return testMatchPatterns.some(pattern =>
typeof pattern === 'string' ? micromatch.isMatch(fileName, pattern) : pattern.test(fileName),
)
Expand Down
2 changes: 1 addition & 1 deletion src/config/config-set.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Transformer } from '@jest/transform/build/types'
import { Transformer } from '@jest/transform'
import { Config } from '@jest/types'
import { testing } from 'bs-logger'
import { readFileSync } from 'fs'
Expand Down
4 changes: 2 additions & 2 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ export class ConfigSet {
* @internal
*/
@Memoize()
get testMatchPatterns(): [string, RegExp] {
return this.jest.testMatch.concat(this.jest.testRegex) as [string, RegExp]
get testMatchPatterns(): (string | RegExp)[] {
return [...this.jest.testMatch, ...this.jest.testRegex]
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/shims.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/ts-jest-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CacheKeyOptions, TransformOptions, TransformedSource, Transformer } from '@jest/transform/build/types'
import { CacheKeyOptions, TransformOptions, TransformedSource, Transformer } from '@jest/transform'
import { Config } from '@jest/types'
import { Logger } from 'bs-logger'
import { inspect } from 'util'
Expand Down
10 changes: 4 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { TransformedSource, Transformer } from '@jest/transform/build/types'
import { TransformedSource, Transformer } from '@jest/transform'
import * as _babel from 'babel__core'
import { CompilerOptions, SourceFile, TransformerFactory } from 'typescript'
// tslint:disable-next-line:no-duplicate-imports
import * as _ts from 'typescript'

import { ConfigSet } from './config/config-set'
Expand Down Expand Up @@ -37,7 +35,7 @@ export interface TsJestGlobalOptions {
* - `path/to/tsconfig.json`: path to a specific tsconfig file (<rootDir> can be used)
* - `{...}`: an object with inline compiler options
*/
tsConfig?: boolean | string | CompilerOptions
tsConfig?: boolean | string | _ts.CompilerOptions

/**
* packageJson. It can be:
Expand Down Expand Up @@ -122,7 +120,7 @@ interface TsJestConfig$tsConfig$file {
}
interface TsJestConfig$tsConfig$inline {
kind: 'inline'
value: CompilerOptions
value: _ts.CompilerOptions
}
type TsJestConfig$tsConfig = TsJestConfig$tsConfig$file | TsJestConfig$tsConfig$inline | undefined
interface TsJestConfig$diagnostics {
Expand Down Expand Up @@ -227,5 +225,5 @@ export interface CompilerInstance {
export interface AstTransformerDesc {
name: string
version: number
factory(cs: ConfigSet): TransformerFactory<SourceFile>
factory(cs: ConfigSet): _ts.TransformerFactory<_ts.SourceFile>
}

0 comments on commit b3c55d6

Please sign in to comment.