setupServer / setupWorker type issues on ts strict mode
See original GitHub issueDescribe the bug
After upgrading to 0.21.0 typescript in strict mode is complaining when registering handlers to setupServer
or setupWorker
.
Tried it both using the new RequestBodyType
and without.
Environment
msw: 0.21.0
nodejs: 12.18.3
npm: 6.14.6
To Reproduce
Steps to reproduce the behavior:
- Clone https://github.com/deini/msw-types
- npm install
- npm run test
Expected behavior
No typing errors
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:11 (5 by maintainers)
Top Results From Across the Web
setupServer() - Api - Mock Service Worker Docs
This function is designed for NodeJS environment. If looking for a way to apply API mocking in a browser environment, consider using setupWorker...
Read more >How strict is Typescript's strict mode? - DEV Community
According to the docs, when Typescript strict mode is set to on, it will validate your code using the strict type rules under...
Read more >msw: Versions - Openbase
Fixes type annotations of ResponseTransformer to drop the usage of the unknown generics causing type violations in strict mode (#381, #382). 0.21.1. 2...
Read more >Msw With React - Dennis O'Keeffe Notes
4export const worker = setupWorker(...handlers); ... StrictMode> ... 13// if you need to add a handler after calling setupServer for some specific test....
Read more >How to develop an offline Front-End app with mock data
This kind of seamless integration is what we are aiming for today! ... the browser.ts file dynamically only when we are in development...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aldis-ameriks, @emmenko, thank you for the follow up! I’ve issued https://github.com/mswjs/msw/pull/382 where we drop all the
unknown
generics altogether. Could you see if that PR fixes your usage? Thanks.After pulling
0.21.1
, I’m seeing these types of typing errors.