-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Discriminated unions behave inconsistently since v4.6 #49475
Comments
Isnβt this a correct error? I thought that in general |
I didn't bother penciling it out, because something is totally screwed up if uncommenting the two commented-out lines changes the errorness of the program. That's the key bug here. |
What's interesting here is that while we decide that I bisected this to #47907 (the 4.6 cherry pick of #47738), which doesn't seem to have been intended to add errors, only remove unrelated elaborations. To me it seems like these two types are supposed to be related as they used to be in 4.5 but we are now reporting an error on this class case. If we check related twice, then ISTM what is happening is that we get the cached "yes, it's related" result and then don't error, but something about the class case is different. I'm still debugging. |
It was as I thought above. The linked refactor must have changed things enough such that the error didn't get cleared out when @azhiv after the #49718, this error should go away again. @fatcerberus while that's true, there's an exception via |
vacuous truth is always a fun bit of logical trickery isnβt it π |
@jakebailey I'm utterly glad this error will be gone and we won't have to rewrite those pieces of our codebase. Thank you very much for the thorough investigation you have conducted! |
@jakebailey Will the fix be backported to 4.6.x and/or 4.7.x? |
I don't think this will be back-ported, but you can use a nightly in the meantime until 4.8 is out. npm install -D typescript@next |
Bug Report
π Search Terms
Discriminated union
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Class
A
doesn't acceptModel
as generic parameter with the following error:The basic example above hadn't emitted any errors prior to v4.6. Furthermore, if you uncomment the code that declares and executes function
foo
, the compiler error vanishes.π Expected behavior
The code is compilable in 4.6+ without any workarounds.
The text was updated successfully, but these errors were encountered: