Skip to content

Stop elaborating errors when relating intersection constituents #7203

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

Merged
merged 9 commits into from
Feb 25, 2016

Conversation

DanielRosenwasser
Copy link
Member

Fixes #7199

@@ -5522,7 +5522,7 @@ namespace ts {
// A & B = (A & B) | (C & D).
if (source.flags & TypeFlags.Intersection) {
// If target is a union type the following check will report errors so we suppress them here
if (result = someTypeRelatedToType(<IntersectionType>source, target, reportErrors && !(target.flags & TypeFlags.Union))) {
if (result = someTypeRelatedToType(<IntersectionType>source, target, reportErrors && !(target.flags & (TypeFlags.Union | TypeFlags.ObjectType)))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should use structural error reporting for other things, too, like primitives or type parameters.

@DanielRosenwasser DanielRosenwasser changed the title Don't elaborate errors on intersection constituents when relating to object types Stop elaborating errors when relating intersection constituents Feb 24, 2016
@DanielRosenwasser
Copy link
Member Author

@sandersn @RyanCavanaugh any thoughts?

@RyanCavanaugh
Copy link
Member

Seems like the change is simple enough and the baselines look improved. What's the worst-case scenario here?

@sandersn
Copy link
Member

The worst scenario I could come up with is the case that the error message happens when relating a multiple intersection of giant types, say 1000+ members each. Then the error "A is not assignable to B & C & D & E & F & G -- 'A.a' is 'string' but 'B & C & D & E & F & G.a' is 'number'." means you have to go searching through B, C, D, E, F and G to find and fix property 'a'.

This kind of type is common in big data/relational code, say Spark or U-SQL. In U-SQL (which I'm more familiar with), the above type results from joining giant tables, eg Clicks JOIN Pages JOIN Users JOIN Ads. Right now Spark officially supports Scala, Python and R but there is already an unofficial Node project. So real users could run into this scenario someday.

On the other hand, I think insufficient elaboration is better than confusingly-wrong elaboration, so I vote that we take this change. 👍

@RyanCavanaugh
Copy link
Member

👍

DanielRosenwasser added a commit that referenced this pull request Feb 25, 2016
Stop elaborating errors when relating intersection constituents
@DanielRosenwasser DanielRosenwasser merged commit 713c0e0 into master Feb 25, 2016
@DanielRosenwasser DanielRosenwasser deleted the intersectionErrors branch February 25, 2016 00:26
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants