Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave the string return here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee Unfortunately not; the enzyme-to-json type declaration for JestSerializer has print returning their Json type which is an object.

https://github.com/adriantoine/enzyme-to-json/blob/d1f86ee82ce014bb3d63f521a5d553307948eff0/index.d.ts#L24

Keeping it as string give this error:

Type 'JestSerializer' is not assignable to type 'Serializer'.
  Types of property 'print' are incompatible.
    Type '(CommonWrapper: any, serializer: JestSerializer) => Json' is not assignable to type '(value: any, _serializer?: any) => string'.
      Type 'Json' is not assignable to type 'string'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wasn't aware. That's fine then

diffOptions?: (valueA: any, valueB: any) => DiffOptions;
}

declare module 'snapshot-diff' {
Expand Down