@@ -16,26 +16,24 @@ function importBabelDeps() {
1616 istanbulPlugin = require ( 'babel-plugin-istanbul' ) . default ;
1717 jestPreset = require ( 'babel-preset-jest' ) ;
1818}
19- import { CompilerOptions } from 'typescript/lib/typescript ' ;
19+ import { CompilerOptions } from 'typescript' ;
2020import {
2121 BabelTransformOptions ,
22- CodeSourceMapPair ,
23- JestConfig ,
2422 PostProcessHook ,
25- TransformOptions ,
23+ JestCacheKeyOptions ,
2624 TsJestConfig ,
27- } from './jest- types' ;
28- import { logOnce } from './logger' ;
25+ } from './types' ;
26+ import { logOnce } from './utils/ logger' ;
2927
3028// Function that takes the transpiled typescript and runs it through babel/whatever.
3129export function postProcessCode (
3230 compilerOptions : CompilerOptions ,
33- jestConfig : JestConfig ,
31+ jestConfig : jest . ProjectConfig ,
3432 tsJestConfig : TsJestConfig ,
35- transformOptions : TransformOptions ,
36- transpileOutput : CodeSourceMapPair ,
33+ transformOptions : jest . TransformOptions ,
34+ transpileOutput : jest . TransformedSource ,
3735 filePath : string ,
38- ) : CodeSourceMapPair {
36+ ) : jest . TransformedSource {
3937 const postHook = getPostProcessHook (
4038 compilerOptions ,
4139 jestConfig ,
@@ -58,11 +56,11 @@ function createBabelTransformer(
5856 delete options . filename ;
5957
6058 return (
61- codeSourcemapPair : CodeSourceMapPair ,
59+ codeSourcemapPair : jest . TransformedSource ,
6260 filename : string ,
63- config : JestConfig ,
64- transformOptions : TransformOptions ,
65- ) : CodeSourceMapPair => {
61+ config : jest . ProjectConfig ,
62+ transformOptions : JestCacheKeyOptions ,
63+ ) : jest . TransformedSource => {
6664 const theseOptions = Object . assign (
6765 { filename, inputSourceMap : codeSourcemapPair . map } ,
6866 options ,
@@ -81,17 +79,18 @@ function createBabelTransformer(
8179 ] ,
8280 ] ) ;
8381 }
84- // Babel has incorrect typings, where the map is an object instead of a string. So we have to typecast it here
85- return ( babel . transform (
82+
83+ // we typecast here because babel returns a more complete object than the one expected by jest
84+ return babel . transform (
8685 codeSourcemapPair . code ,
8786 theseOptions ,
88- ) as any ) as CodeSourceMapPair ;
87+ ) as jest . TransformedSource ;
8988 } ;
9089}
9190
9291export const getPostProcessHook = (
9392 tsCompilerOptions : CompilerOptions ,
94- jestConfig : JestConfig ,
93+ jestConfig : jest . ProjectConfig ,
9594 tsJestConfig : TsJestConfig ,
9695) : PostProcessHook => {
9796 if ( tsJestConfig . skipBabel ) {
0 commit comments