diff --git a/packages/babel-jest/src/index.ts b/packages/babel-jest/src/index.ts index cacdce09a9f9..7a23fecc252f 100644 --- a/packages/babel-jest/src/index.ts +++ b/packages/babel-jest/src/index.ts @@ -23,10 +23,11 @@ const THIS_FILE = fs.readFileSync(__filename); const jestPresetPath = require.resolve('babel-preset-jest'); const babelIstanbulPlugin = require.resolve('babel-plugin-istanbul'); -// Make it non-optional -type TransformerWithFactory = Transformer & { +// Narrow down the types +interface TransformerWithFactory extends Transformer { + canInstrument: true; createTransformer: (options?: TransformOptions) => TransformerWithFactory; -}; +} const createTransformer = ( options: TransformOptions = {}, diff --git a/packages/jest-transform/src/types.ts b/packages/jest-transform/src/types.ts index 9d3bf1dc7d6e..91df3f394de9 100644 --- a/packages/jest-transform/src/types.ts +++ b/packages/jest-transform/src/types.ts @@ -51,7 +51,7 @@ export type CacheKeyOptions = { rootDir: string; }; -export type Transformer = { +export interface Transformer { canInstrument?: boolean; createTransformer?: (options?: any) => Transformer; @@ -68,4 +68,4 @@ export type Transformer = { config: Config.ProjectConfig, options?: TransformOptions, ) => string | TransformedSource; -}; +}