Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update serializer types to support enzyme-to-json #109

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