Skip to content

Commit 4f6b1ed

Browse files
alistairjcbrownthymikee
authored andcommitted
Update serializer types to support enzyme-to-json (#109)
Current type declaration for serializer causes errors when used with `enzyme-to-json`. Changes: * `diffOptions` is now an optional parameter (as it is in code). * Type declaration for the second `serialize` parameter of the `print` function has been weakened to `any` due to incorrect type used in `enzyme-to-json` (should be function, but has been typed serializer) * Return type declaration from `print` function has been weakened to `any`; this function is not limited to only returning strings. Conflicting `enzyme-to-json` declaration: https://github.com/adriantoine/enzyme-to-json/blob/d1f86ee82ce014bb3d63f521a5d553307948eff0/index.d.ts#L22-L25 Mismatch of `enzyme-to-json` `serializer` type in `print` function: https://github.com/adriantoine/enzyme-to-json/blob/d1f86ee82ce014bb3d63f521a5d553307948eff0/src/createSerializer.js#L9-L11 Fixes #108
1 parent b03936d commit 4f6b1ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ declare namespace jest {
2525

2626
interface Serializer {
2727
test: (value: any) => boolean;
28-
print: (value: any, _serializer?: Function) => string;
29-
diffOptions: (valueA: any, valueB: any) => DiffOptions;
28+
print: (value: any, _serializer?: any) => any;
29+
diffOptions?: (valueA: any, valueB: any) => DiffOptions;
3030
}
3131

3232
declare module 'snapshot-diff' {

0 commit comments

Comments
 (0)