Skip to content

Commit

Permalink
interface over type so we can extend
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 17, 2019
1 parent 6809772 commit b8f59c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/babel-jest/src/index.ts
Expand Up @@ -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 = {},
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-transform/src/types.ts
Expand Up @@ -51,7 +51,7 @@ export type CacheKeyOptions = {
rootDir: string;
};

export type Transformer = {
export interface Transformer {
canInstrument?: boolean;
createTransformer?: (options?: any) => Transformer;

Expand All @@ -68,4 +68,4 @@ export type Transformer = {
config: Config.ProjectConfig,
options?: TransformOptions,
) => string | TransformedSource;
};
}

0 comments on commit b8f59c8

Please sign in to comment.