-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
feat: support TypeScript 5.2 #1711
Conversation
I've updated the branch against the latest main. |
Looks like we are getting a consistent TS compilation error: Error: src/utils/request/MockedRequest.ts(119,34): error TS2345: Argument of type 'HeadersPolyfill' is not assignable to parameter of type 'Headers'.
Property 'getSetCookie' is missing in type 'HeadersPolyfill' but required in type 'Headers'. I suspect that something might have changed regarding the validation in this regard, or the |
DOM type updates from 5.2 are here looks like https://github.com/microsoft/TypeScript/pull/54725/files#diff-dc0eab937d15e62545da3ed7b4f40ad6b24f15dd88fbc6ceda2bfb4ed8356eb0R13429 is the line that added the method in question related mdn docs - https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie |
@kettanaito - mswjs/headers-polyfill#57 should implement the method this PR fails type checks from, on the header-polyfill package |
Thank you for opening a pull request in such a timely manner, @mattcosta7 🙌 My main concern is what would happen with the older versions of TypeScript where Could someone please give it a try on TS < 5.2? I expect it either to break or TS to be smart about it and treat a class with extra methods as satisfying the class with narrower expected methods (I hope very much that's the case). |
A new version of |
|
may need to change the tsconfig.5.2.2 file to use a different |
@mattcosta7, that's odd. I thought that module resolution has changed as far back as 4.9/5.0. But agree on the strategy, we need to introduce a new base config for this version of TS with the right module resolution set. |
typescript added this error in 5.2 - https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#module-and-moduleresolution-must-match-under-recent-node-js-settings so it might not have correct before, but only causes issues in 5.2+ See the PR that added this here: microsoft/TypeScript#54567 |
Thanks for sharing, @mattcosta7. I've noticed 5.2 extended 4.7 config that had I set explicit module and moduleResolution values to |
I've also noticed that |
The tests are passing. Let me know if any more changes are intended here. Otherwise, we can merge and release. |
I think we're ready to merge and release this. |
Thanks for seeing this improvement through, @chentsulin, @mattcosta7! |
Could you please release this change to npm? |
Hello, thanks a lot for the changes, any ETA on the npm release ? 🙂 |
Released: v1.3.0 🎉This has been released in v1.3.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Loosen peer dependency constraint to unblock projects that use msw from upgrading to TypeScript 5.2.x.