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
{{ message }}
Repository navigation
cannot enforce type shape when assigned to a conjunction #28642
I'm guessing this type relaxation is required in certain scenario (with named members), however, with an indexed type on string (covering both 'a' and 'b'), I would rather expect it to fail.
Activity
[-]conjunction assignable wrong type[/-][+]cannot enforce type shape when assigned to a conjunction[/+]sledorze commentedon Nov 21, 2018
I'm guessing this type relaxation is required in certain scenario (with named members), however, with an indexed type on string (covering both 'a' and 'b'), I would rather expect it to fail.
jack-williams commentedon Nov 21, 2018
From the spec: S is a subtype of T if S is an intersection type and at least one constituent type of S is a subtype of T. (same for assignability).
T & Uis assignable toXifTis assignable toX.{ a: string }is assignable to{ [k: string]: string }String indexers are unsound like this when properties are 'forgotten'. Another example:
{ a : string; b: number }is assignable to{ a: string }{ a: string }is assignable to{ [k: string]: string }sledorze commentedon Nov 21, 2018
Jack Williams (@jack-williams) indeed.
The amount of consequences of the unsoundness is frightening.
MartinJohns commentedon Nov 21, 2018
Jack Williams (@jack-williams) Quoting the spec is not advised, as the spec was last updated around 3 years ago.
jakebailey commentedon Jul 11, 2023
This was fixed by #35143, whose description contains effectively this issue's repro