From b8f59c884a295ed94b66e0511406ae6939c9093f Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 17 Feb 2019 01:18:37 +0100 Subject: [PATCH] interface over type so we can extend --- packages/babel-jest/src/index.ts | 7 ++++--- packages/jest-transform/src/types.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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; -}; +}