Misleading error message "'{}' and 'number' have no overlap" #60583
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
π Search Terms
empty object type, unintentional comparison
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?noUncheckedIndexedAccess=true&target=99&ts=5.8.0-dev.20241124#code/JYMwBAFA3gvmC8iwAYCUZZA
π» Code
π Actual behavior
TS 2367: "This comparison appears to be unintentional because the types '{}' and 'number' have no overlap."
π Expected behavior
TS 2367: "This comparison appears to be unintentional because the types 'object' and 'number' have no overlap."
Additional information about the issue
the type
{}
andnumber
do have overlap;number
is a subset of{}
.TS is correct to report an error, but it should give a technically correct reason for the error.
Analogous (very contrived) examples can be made for similar coincidentally-including-primitive types, like
Stems from discord discussion beginning here: https://discord.com/channels/508357248330760243/508357638677856287/1310419206260654081
Closely related to discussion regarding #60582
The text was updated successfully, but these errors were encountered: