Open VincentLanglet opened 5 years ago
In the index.d.ts, we have
export interface JestSerializer { test: (CommonWrapper: CommonWrapper) => boolean; print: (CommonWrapper: CommonWrapper, serializer: JestSerializer) => string; } export declare function createSerializer(options?: Options): JestSerializer;
But when we use it like this
import { createSerializer } from 'enzyme-to-json'; expect.addSnapshotSerializer(createSerializer());
We receive a typescript error because addSnapshotSerializer is type like this
addSnapshotSerializer
interface SnapshotSerializerPlugin { print(val: any, serialize: ((val: any) => string), indent: ((str: string) => string), opts: SnapshotSerializerOptions, colors: SnapshotSerializerColors): string; test(val: any): boolean; } addSnapshotSerializer(serializer: SnapshotSerializerPlugin): void;
I think it would be better to type createSerializer like this
/// <reference types="jest"/> export declare function createSerializer(options?: Options): jest.SnapshotSerializerPlugin
In the index.d.ts, we have
But when we use it like this
We receive a typescript error because
addSnapshotSerializer
is type like thisI think it would be better to type createSerializer like this