-
Notifications
You must be signed in to change notification settings - Fork 12.8k
5.1 regression: constraints of generic tuple types are sometimes order-sensitive #54495
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
Comments
I'm not able to reproduce this error. Can you post a concrete example? |
@RyanCavanaugh I tried to put together an MWE but I couldn't figure it out. For some reason the error only happens with io-ts as a dependency of a dependency. The middle dependency compiles just fine with TS 5.1 and the issue only happens downstream with the transpiled JS and declaration files being used in 5.1. Do you have any advice on how to get more information from TS, or a good guess at what might be the actual issue for me to narrow my search? |
I'd recommend bisecting your situation by removing code from your dependencies, once you minimize this to a minimal repro you might want to just commit |
Okay @RyanCavanaugh @Andarist I've got a minimal repro repo. Turns out, nothing to do with our code, so either a TS bug, or a bug with another repo (still looks like TS to my uneducated eye, though). The repro case β in the end β was laughably simple: import 'mongodb';
import 'io-ts'; βπΌ this fails to build with a bare-bones It builds fine on TypeScript v5.0.4. |
Please let me know if this is actually a bug with import 'mongodb';
- import 'io-ts'; or - import 'mongodb';
import 'io-ts'; both work |
Full error dump
|
This can be bisected to this PR #53672 , cc @ahejlsberg That being said, this isn't quite a minimal repro case π Note that reordering those 2 imports also fixes the issue so it's likely a caching bug in the compiler. Things are cached for performance reasons and unfortunately, sometimes issues like this pop up and at times it's hard to fix them. Ideally, the order of declarations shouldn't matter but in practice, it sometimes might. |
Sorry I guess I meant minimal in terms of code I actually wrote π Unfortunately I'm not sure I personally have time to unpick the internal type dependencies of these packages π¬ @Andarist I'm not really sure I understand what the actual issue is: do you have a suggestion for a more accurate issue title for this? |
Maybe something like: "5.1 regression: constraints of generic tuple types are sometimes order-sensitive" |
Okay I spotted something as I was skimming the MongoDB type declarations, and it looks like if you comment out this suspicious-looking type (and things that depend on it), everything compiles just fine. I've pushed the result to the above repo as a new branch: Is this a TypeScript bug or a MongoDB bug? |
@Andarist @ahejlsberg this is still broken in |
It seems that the fix was supposed to be cherry-picked into 5.1 but the automated job failed, see the comment here. cc @DanielRosenwasser @jakebailey |
I just sent #54814 to cherry-pick it by hand. Unfortunate; I totally read that notification in my email but I figured it was already handled... |
Bug Report
π Search Terms
Possibly related:
π Version & Regression Information
β― Playground Link
I was unable to reproduce: if you could please steer me in the right direction I'm happy to dig more, but I'm a bit stuck on how to debug this
π» Code
We have an issue using
io-ts
. If this is a bug with that library, I'll close this here, but I don't think it is.The TypeScript compiler is complaining about a number of excerpts from the
d.ts
file, where the compiler doesn't seem to be making sense.Here's an example error:
The code it's referring to is here:
As you can see, the compiler seems to be collapsing the
[Mixed, Mixed, ...Array<Mixed>]
to[Mixed, Mixed, Mixed[]]
, which is incorrect. It then doesn't likeCS
extending[Mixed, Mixed, ...Mixed[]]
, which it considers incompatible with its incorrect collapsing.Weirdly, if I tweak the
d.ts
file by hand, the error goes away:π Actual behavior
Compilation errors
π Expected behavior
Successful compilation
The text was updated successfully, but these errors were encountered: