-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type instantiation is excessively deep not reported with a complex type involving a conditional type and another aliased conditional type #50017
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
bug |
Wait, what? Generally we do lots of effort to avoid issuing this error; it's always bad. Why is issuing the error desirable here? |
Yeah, actually my original repro was to try to remove this error for good. And that's when @Andarist found that there was a behavioral difference between both options. |
I don't mind this not being an error. The only thing that I care about it here is consistency. I've just figured out that it might be preferable (or at least easier) to make this an error rather than to make the error go away for all of those cases. |
I don't think there's anything to fix here. For any potential analytical situation where there's a problem (infinite instantiation) that is sometimes avoidable through additional smarts, it'll always be possible to write two similar programs on either side of that boundary line. If anyone wants to send a PR to move that boundary in the good direction that's fine, but the existence of the boundary itself can't be considered a defect. |
Hm, so is it expected that sometimes using an equivalent type through an alias can move the mentioned boundary? The main problem I've seen here is that using a type alias You are mentioning that it will always be possible to write two similar programs and land them on either side of that boundary. I agree with that. I'd just like to make a last check if those two programs are considered to be similar because I've considered them to be the same in the same sense that those are the same: // program1
const result = 2 + 2
// program2
function add(a, b) { return a + b }
const result = add(2, 2) If extracting parts a more complex type to type aliases (without changing its traits, such as homomorphism, distributivity, etc, in the process) is considered to produce a different/similar program then I'm OK with closing this. |
Sure, since type aliases can have their variances measured (thus potentially allowing a shortcut measure of the relation between |
Bug Report
π Search Terms
NonNullable, conditional type, excessively deep
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
It doesn't error on the template literal type.
π Expected behavior
It should error on the template literal type.
I believe that it should error because:
NonNullable
change (from a conditional type toT & {}
). The slimmed down version that I've created doesn't error in the nightly build though. Original repro by @SferaDev can be found here: 4.7 with no error, 4.8 nightly with the errorIf<IsArray<O[K]>, ..., ...>
alias then it starts to error in all of the versions of the slimmed down repro: TS playground. To the best of my knowledge the aliased version and inlined version should not differ in their observable behaviors.I understand that the repro is not small - I've tried to reduce it further but I couldn't. The problem at hand seems to be quite complex and involves a very specific ingredients from what I can tell.
The text was updated successfully, but these errors were encountered: