-
Notifications
You must be signed in to change notification settings - Fork 12.8k
#31711 breaks assignability #31762
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
Found in the user tests, in prettier. |
Looks like it got the assignability check backwards, that’s odd. |
From in-person discussion, I think we are going to take this as a breaking change for 3.6. |
Wait, what's the accepted breaking change? The error mentioned in the OP? Because if so the error message is nonsensical:
With that wording, it looks like a bug--the apparent bug being that a structural assignability check was done with the source and target swapped. Even if the breakage is acceptable, the error message IMO isn't as it's exactly backwards a.c.t. typical structural typing semantics. |
The issue here is when to widen the object expression in property access ( I've given it some thought, and I think the real solution is to widen |
To demonstrate the inconsistency, this is our behavior in 3.5.1 and earlier: // @strict: true
function g1(headerNames: any) {
let t = [{ hasLineBreak: false, cells: [] }];
const table = [{cells: headerNames }].concat(t); // No error
}
function g2(headerNames: any) {
let t = [{ hasLineBreak: false, cells: [] }];
const table = [{cells: headerNames }]["concat"](t); // Error
} |
@ahejlsberg I’m not actually doubting the type error itself - I’m just confused as to how TypeScript arrives at the conclusion that “ // @strictFunctionTypes: true
let f: (x: Derived) => void;
let g: (x: Base) => void;
g = f;
// error because (ultimately) Base is not assignable to Derived |
Expected behavior:
No error.
Actual behavior:
Error on
concat(t)
:{ hasLineBreak: boolean, cells: never[] }
is not assignable to{ cells: any }
.hasLineBreak
is missing.Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: