Argument of type X is not assignable to parameter of type Y, but then assignable. - Misleading error #50438
Labels
Cursed?
It's likely this is extremely difficult to fix without making something else much, much worse
Experience Enhancement
Noncontroversial enhancements
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
Bug Report
🔎 Search Terms
Argument of type is not assignable to parameter of type, object properties overlap
🕗 Version & Regression Information
The closest I could find in the FAQ is this https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-all-types-assignable-to-empty-interfaces
Type
{ color: "red", margin: 1 }
has the required member ofProps
, so it may correctly be evaluated by TS as fitting, however, the error in the first place is then misleading.⏯ Playground Link
same result with 4.8.0-beta
Playground link with relevant code
💻 Code
Since
{margin: 1}
is clearly tolerated, the error given is misleading as the actual error is not in the presence ofmargin
but in the absence ofcolor
, which is a property required by theProps
type.🙁 Actual behavior
Argument of type '{ margin: number; }' is not assignable to parameter of type 'Props'. Object literal may only specify known properties, and 'margin' does not exist in type 'Props'.(2345)
🙂 Expected behavior
Argument of type '{ margin: number; }' is not assignable to parameter of type 'Props'. Object literal does not specify properties required by 'Props'.(2345)
The text was updated successfully, but these errors were encountered: