Skip to content

Reduce away intersections that aren't assignable to constituents in CFA - #37724

Closed
Anders Hejlsberg (ahejlsberg) wants to merge 2 commits into
masterfrom
fix37659
Closed

Anders Hejlsberg (ahejlsberg) wants to merge 2 commits into
masterfrom
fix37659

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #37659.

@weswigham

Wesley Wigham (weswigham) commented Mar 31, 2020 •

Copy link
Copy Markdown
Member

Anders Hejlsberg (@ahejlsberg) shouldn't A & B be assignable to A in this case? A & B by definition has all of A's private fields, no?

@ahejlsberg

Copy link
Copy Markdown
Member Author

Wesley Wigham (@weswigham) Well, yes, but A and B also have a conflicting private member x and we consider it an error to access conflicting members (introduced years ago in #13990). The access happens as we're checking the properties from the whole intersection against the properties of each of A and B, a check that was introduced recently in #37195.

@ahejlsberg

Copy link
Copy Markdown
Member Author

Wesley Wigham (@weswigham) We're basically trying to have it both ways. It would seem reasonable for A & B to be assignable to A and B even with the conflicting private properties, yet we rely on an error being issued in the link below as an early warning that a mixin produced an invalid type.

https://github.com/microsoft/TypeScript/pull/13990/files#diff-4b0cabe62740b5899b9a7850e502007aR95

@ahejlsberg

Copy link
Copy Markdown
Member Author

Superceded by #37762.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants