-
Notifications
You must be signed in to change notification settings - Fork 22
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
TypeScript error when passing enzymeToJson to setSerializers #108
Comments
@simonsmith Thanks for the great debugging notes! |
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 jest-community#108
@simonsmith PR is up - could you take a look and see if that solves the issue? |
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
@alistairjcbrown Working fine now. Thank you for the rapid PR! 👍 |
Hello, here is my setup code:
test-setup.ts
This produces the following error:
This seems like a mismatch between the
Serializer
type in this repository and theJestSerializer
type fromenzyme-to-json
.My understanding is that a serializer should only have two required properties (
print
andtest
) so perhapsdiffOptions
needs to be optional? Note that it appears the source code expects it to be optional alreadyIf I try to make that change I get:
Let me know if I can provide further debugging help, thanks
The text was updated successfully, but these errors were encountered: