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
Support TypeScript 4.8 #1376
Comments
can a supported TS support matrix be added to C.I.? |
Hey, @CreativeTechGuy. I'm sorry to hear about your painful updating experience. The thing is, TypeScript is a dependency like any other. Only, TypeScript is released in this completely strange way. Did you know that minor versions of You can find the versions MSW supports officially in this matrix: Line 47 in b93aca9
We run type compilation on each change with all those versions to ensure there are no regressions introduced. You can also notice that 4.8 is, respectively, not in the matrix. If you want to have 4.8 support, you can tackle it head-on:
Hope this answers your question. I'm going to rename this issue to "TypeScript 4.8 support" as we are not going to migrate from the explicit TypeScript |
Oh, I've just noticed that @dargmuesli has opened a pull request that adds the 4.8 support! #1375 That's exciting. Let's see what the tests tell us. |
Hi @kettanaito! Yes I am aware that TypeScript doesn't follow semver and both minor and major versions are breaking changes. It's peculiar though that msw is the only dependency out of hundreds that I've checked which limits the maximum TypeScript version which can be used. While TypeScript can have breaking changes at any point, they rarely do (and the breaking changes would likely not impact msw consumers). So this is likely going to cause more pain more often rather than actually catching a real breaking change. For completeness: I'm wasn't suggesting depending on
Can you link to what you are referring to? I'd love to look into this more since this is the first time I've ever heard about a library needing to restrict the maximum TypeScript version that their consumers use. |
I tend to disagree here. I recall migrating to the next minor version a couple of months back and it was a huge pain for me, as the consumer. The fact that others don't limit the TypeScript version doesn't mean that specifying a supported range is bad at its core. You need to look at their use cases and how their code is consumed. People consume MSW in TypeScript projects and automatically become dependent on MSW's type declarations being compatible with whichever version of TS they're using. If there's a type violation, their entire app compilation breaks. Ouch.
You can learn more about the issues we've faced in the pull request that introduced the original I can also phrase it a little differently: I'd rather have a strict peer dependency policy than have to spend my time on issues where people are using the bleeding edge TypeScript and complaining that MSW breaks things for them. This creates two quite distinct kinds of thinking:
Because, in actuality, we can give 0 guarantees that MSW will compile on any minor version of TypeScript. Those versions ship breaking changes by definition, and rightfully so. How can the library promise automagical compatibility with whichever range of versions? Keeping in mind how TS is released, it's the same as stating:
I wouldn't want to maintain that kind of software, to be honest. |
Got it. Thanks for explaining. I see it this way. TypeScript has a new major version every few months. It seems like once in the past year there's been an issue with msw as a result. The maintenance overhead of having to manually update msw to each new TypeScript version and blocking every consumer from updating until you do is far more than occasionally having to fix a bug from the latest TS version breaking something. Because importantly, there's no way that a TypeScript issue will cause any runtime impacts on the consumer. It would, at worst, break their build and so they'd just downgrade and report the bug. I guess it's good that msw gets enough maintenance support that things like this are updated quickly. Eventually there'll be a day when maintenance slows down or stops completely and an issue like this will quickly make the package unusable even if it otherwise would have worked just fine. Seriously appreciate the discussion! 😃 |
TypeScript is an optional peer dependency. The way its version mismatch is handled is purely up to the package manager you're using. I wouldn't say it breaks projects. If anything, you can disable the peer dependency warning and try things out. But I get where you're coming from. I came to the conclusion that we can only promise support for those TS versions for which we have automated tests. Having to try out all the possible versions that may have issues is insane. Have a CI—have proof! From this perspective alone, removing a version range while deliberately keeping a fixed and known matrix of supported versions seems wrong. People complain, being confused because we don't specify which versions are officially supported. The only useful place to specify that is
That's precisely why I'm tentative to have a loose version range. I don't want to get a potential issue every time TS does a release. Once again, I'm much more comfortable with closing an issue on a TS version that has no official proof of support or accepting a pull request for it. Both come from my wish to minimize the amount of time I spend on the issues. I was actually going to close this one as well, suggesting opening a pull request. But since one is already open, I left it intact. But I don't agree with the points presented still. What we have, effectively, is this:
Sure, having to bump dependencies when updating that package sucks. But that's sort of the path for breaking changes, isn't it? You can't rely on that there are no breaking changes between versions that clearly indicate a breaking change. So the entire request comes down to:
That's the point of breaking versions and type ranges. TypeScript is not a special sunflower here (it's just released like one). While it may feel like a nuisance, it's a regular dependency update cycle, and all tools go through one when their dependencies get a new breaking version. |
Thanks for this! At the very least I've learned a new perspective which is always valuable. Appreciate it! |
Here's a recent example of how migrating from 4.7 to 4.8 breaks things: https://github.com/mswjs/msw/runs/8058492714?check_suite_focus=true. Looks like TS has changed the way types comply with the generic types. Now, in order to officially support 4.8, we need to rewrite our source code so that 4.8 is happy and all the previous versions are as well. Volunteers are welcome! |
Released: v0.46.0 🎉This has been released in v0.46.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.), Firefox, Safari
Reproduction repository
N/A
Reproduction steps
N/A
Current behavior
When trying to update TypeScript to 4.8 (Just released today), we are warned that msw has a peerDependency range for typescript of
>= 4.2.x <= 4.7.x
. As such, it's a pain to force update TypeScript. There's no reason that msw should restrict the maximum TypeScript version we can use in our projects.Expected behavior
It looks like this can be traced to msw features that require a minimum TS version (eg: #429).
Two solutions:
The text was updated successfully, but these errors were encountered: