-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
@@ -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)))) { |
There was a problem hiding this comment.
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.
@sandersn @RyanCavanaugh any thoughts? |
Seems like the change is simple enough and the baselines look improved. What's the worst-case scenario here? |
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 On the other hand, I think insufficient elaboration is better than confusingly-wrong elaboration, so I vote that we take this change. 👍 |
👍 |
Stop elaborating errors when relating intersection constituents
Fixes #7199