-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Misleading error elaboration #25971
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFixedA PR has been merged for this issueA PR has been merged for this issue
Type
Fields
Give feedbackNo fields configured for issues without a type.
TypeScript Version: 3.1.0-dev
Search Terms: Error elaboration
Code
Expected behavior: An error stating
{ a: string, b: number, c: number }is not assignable toT.Actual behavior: Elaboration errors on the
bandcproperty assignments which misleads the user to think the issue is with those properties. The real issue is that no object literal and only aTis assignable toT, and we should not attempt to elaborate here. Generally, the elaboration logic can't rely on the behavior ofgetIndexedAccesswithout first validating that a meaningful type is being requested becausegetIndexedAccesswill happily create deferred indexed access types that technically are errors. The elaboration logic needs to be more selective about which target types it descends into. Specifically, I would suggest only descending into non-generic object types and non-generic intersection types.