-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Regression: something is wrong with type checking in dev.20180919 #27223
Comments
You can work around this for now by adding manual type arguments |
This is actually working as intended. The error is caused by fixes in #26698 which improve accuracy of reasoning over constraints of indexed access types (types of the form The following simplified repro previously wasn't an error but now is: function f1<S, T extends { state: S }>(s: S, t: T["state"]) {
s = t;
t = s; // Error, S not assignable to T["state"]
} The error definitely is correct-- function f2<S, T extends S>(s: S, t: T) {
s = t;
t = s; // Error, S not assignable to T
} |
Well, this raises the question: I want to say |
Why not just |
Good point, @andy-ms. I should mention that the repro example code above is not the real code, and in real code I may have a good reason to use a type parameter |
TypeScript Version: Version 3.1.0-dev.20180919
Code
This code compiles in v3.0.3 but fails in 3.1.0-dev.20180919.
Expected behavior:
Compiles without error.
Actual behavior:
Playground Link: No error in Playground.
The text was updated successfully, but these errors were encountered: