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
Bug from #23592 - Type 'keyof U & K' does not satisfy the constraint 'string | number | symbol' #23648
The issue here is that we don't lift constraints over intersection types. Here's a simpler repro:
functionfoo<Textendsstring|number,Uextendsstring|number>(x: T&U){lety: string|number=x;// Error, but shouldn't be}
We need to lift the individual constraints of T and U such that the intersection type T & U appears to have the constraint string | number (formed by intersecting the individual constraints of T and U).
Activity
ahejlsberg commentedon Apr 24, 2018
The issue here is that we don't lift constraints over intersection types. Here's a simpler repro:
We need to lift the individual constraints of
TandUsuch that the intersection typeT & Uappears to have the constraintstring | number(formed by intersecting the individual constraints ofTandU).ahejlsberg commentedon Apr 24, 2018
The reason this shows up with #23592 is that we now have union type constraints for
keyof T.ahejlsberg commentedon Apr 24, 2018
Mohamed Hegazy (@mhegazy) Do you recall if we already have an issue for this?
mhegazy commentedon Apr 25, 2018
do not think i have seen this one before.