Skip to content

Commit

Permalink
Update serializer types to support enzyme-to-json (#109)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alistairjcbrown authored and thymikee committed Jan 11, 2020
1 parent b03936d commit 4f6b1ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ declare namespace jest {

interface Serializer {
test: (value: any) => boolean;
print: (value: any, _serializer?: Function) => string;
diffOptions: (valueA: any, valueB: any) => DiffOptions;
print: (value: any, _serializer?: any) => any;
diffOptions?: (valueA: any, valueB: any) => DiffOptions;
}

declare module 'snapshot-diff' {
Expand Down

0 comments on commit 4f6b1ed

Please sign in to comment.