-
-
Notifications
You must be signed in to change notification settings - Fork 489
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
Infering the boundary
callback arguments
#2069
Comments
Hi, @Tenga. Thanks for letting me know! I'd love to use this suggestion but it doesn't seem to work in the
|
Released: v2.2.9 🎉This has been released in v2.2.9! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
@Tenga, are you certain you aren't using TS 4.3? MSW doesn't support any TypeScript versions older than 4.7. |
@kettanaito Sorry, yeah I mistyped that somehow. The project (and VS Code) is using |
could you share a repro case of the problem with the current version of MSW? |
@Tenga, in the code snippet above, I'm pretty sure -({ expect }: any)
+({ expect }) Is there any difference if you omit any explicit types? |
That doesn't look like an explicit type annotation but rather like an inlay hint |
Yup, @Andarist is correct, there is no explicit typing in the screenshot. Bright gray text is the VS Code inlay hints that I've enabled to show the inferred types clearly everywhere. The source from the screenshot is identical to the code in the repro case I've provided in my previous post. https://github.com/Tenga/msw-boundary-infer-repro/blob/main/sample.test.ts#L6 |
Scope
Improves an existing behavior
Compatibility
Feature description
Currently, when using the MSW boundaries, the callback provided to the boundary has no inferred types.
This is a slight issue when using boundaries and concurrency, as when using concurrency in Vitest, in certain cases you are required to use the local
expect
from thecontext
instead of the importedexpect
.So I went digging a bit as to what the root cause of this is, and eventually I ran into this issue on the TypeScript repository. I believe this issue also describes the basic interaction between Vitest's
test
typings and MSWboundary
typings.I applied Daniel's suggested alternative to
boundary
locallyand indeed the
boundary
callback's arguments became correctly inferredand I could use the expect from the context with inferred types for it.
I'm unsure if this change would bring something undesireable or if there's something I missed. Correct me if I'm wrong, but I believe that the proposed change's outcome is an improvement as what the current types are trying to do anyway.
The text was updated successfully, but these errors were encountered: