You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Namely, we infer T to be number, and we get an error on blahblah.
However, there are a few things still wrong:
The language service does not show the correct result. It shows both x's to be number, but if you hover on f, you will see that it was instantiated to any, instead of number.
If you add another overload, the wrong type argument gets inferred:
Now suddenly blahblah is not an error, and the second x is any.
In theory, if this overload is not assignable, but it has already fixed the type parameter T, and another overload comes along with a type parameter in the same position, that second type parameter will not get fixed. I don't have a good repro for this, but it is certainly a possibility in theory.
All of these issues happen because when a function expression parameter causes a type parameter to get fixed, it only does so if it is affected by the type of that type parameter. I believe the right thing here is that even if a function parameter does not align with the type parameter, it should still fix it. That way, it will fix the type parameter no matter which signature is being visited, or whether this signature has been visited before.
I consider this bug a followup to bugs #2127 and #2182.
The text was updated successfully, but these errors were encountered:
As of change #2356, the following code gives the correct result in the batch compiler:
Namely, we infer T to be number, and we get an error on blahblah.
However, there are a few things still wrong:
any
, instead ofnumber
.Now suddenly blahblah is not an error, and the second x is
any
.All of these issues happen because when a function expression parameter causes a type parameter to get fixed, it only does so if it is affected by the type of that type parameter. I believe the right thing here is that even if a function parameter does not align with the type parameter, it should still fix it. That way, it will fix the type parameter no matter which signature is being visited, or whether this signature has been visited before.
I consider this bug a followup to bugs #2127 and #2182.
The text was updated successfully, but these errors were encountered: