-
Notifications
You must be signed in to change notification settings - Fork 642
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
Fix typings for snapshot processor #2198
Fix typings for snapshot processor #2198
Conversation
Will take a look this week! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @thegedge, three things:
- praise: thank you for fixing up the docs! That helps a lot.
- nitpick: I added the
describe
import frombun:test
so we can use that with TS. I think that may actually be why you found you wanted@types/jest
in Fix tsconfig and typechecking #2200. We no longer use Jest.bun:test
is mostly a drop in replacement with its own types, but we do need to actually import from that namespace. I pushed that up. - issue: I'm seeing a type error in the
produces the right types when not customized
test:
This goes away if instead we write either:
assertTypesEqual(snapshot, _ as ModelCreationType<{ name: string | undefined }>)
Or
assertTypesEqual(snapshot, _ as SnapshotIn<typeof Model>)
I'm partial to the second one since that's more accessible to users. But I wanted to check to see if you also see this issue or not, and if the SnapshotIn<>
solution changes what we're actually asserting here.
Let me know what you think. Happy to merge this in once we are aligned on this TS error in the test file.
I'm partial to the second one too! And good to know about (2). Thanks for fixing <3 |
Hey @thegedge - ready for another look on my end? |
Oh yeah, totally |
LGTM! I'm gonna merge this and target it as part of the v7 release because I think TS changes are a little nicer behind major versions, even though this is mostly fixing a problem rather than making a sweeping change. |
I think that's fair, given this is a prerequisite for #2199, which is a far more significant typing change! |
What does this PR do and why?
Previously, we weren't properly pulling out the input/output snapshot types of the referenced type in snapshot processors, forcing explicit generic argument specification or typing on the processor functions to avoid
_NotCustomized
:This PR fixes that issue by choosing the given types input/output snapshot if the snapshot processor isn't customized.
Two other small additions in here:
bun.lockb
appeared to be out of date, so I added the updatesxyzProcess
instead ofxyzProcessor
Steps to validate locally
Tests added to validate.