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
Unexpected intersection type constraint error related to union, generic type and private field #38236
Type 'ISyncableObject<object> & T' does not satisfy the constraint 'ISyncableObject<object>'.
Property 'foo' is missing in type 'ISyncableObject<object> & T' but required in type 'ISyncableObject<object>'.(2344)
changed the title [-]Unexpected intersection type constraint error related to primitive union, generic type and private field[/-][+]Unexpected intersection type constraint error related to union, generic type and private field[/+]on Apr 30, 2020
Actually, looks to be caused by #37537. We currently say that unions of object types never contain private or protected members. But that isn't quite right. A union of object types should contain any private or protected member that is present in every constituent and originates in exactly the same declaration. This rarely matters, but in this particular case we end up structurally relating the union ISyncableObject & object | ISyncableObject & string to ISyncableObject, and that fails (but shouldn't) because of the private member.
Activity
DanielRosenwasser commentedon Apr 29, 2020
I'm guessing related to #37762.
[-]Unexpected intersection type constraint error related to primitive union, generic type and private field[/-][+]Unexpected intersection type constraint error related to union, generic type and private field[/+]ahejlsberg commentedon Apr 30, 2020
Actually, looks to be caused by #37537. We currently say that unions of object types never contain private or protected members. But that isn't quite right. A union of object types should contain any private or protected member that is present in every constituent and originates in exactly the same declaration. This rarely matters, but in this particular case we end up structurally relating the union
ISyncableObject & object | ISyncableObject & stringtoISyncableObject, and that fails (but shouldn't) because of the private member.