Clarify type validation error message for == expression
@domlet is already working on this.
Since Jul 9, 2021.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
@ChrisLoer points out that the documentation for `"=="` could be a bit confusing. The docs say:
> Equality is strictly typed: values of different types are always considered not equal
That is true for, e.g., `["==", ["get", "x"], 10]` applied to `{properties: {x: "10"}}`. However, it's _not_ true for an expression like `["==", "10", 10]`, which actually fails to typecheck with the message `Cannot compare string and number.` This error message appears to be in contradiction with the docs.
Let's clarify the message to something like:
> Cannot compare ${toString(lhs.type)} and ${toString(rhs.type)}: since these types are different, "==" would always return false. Consider using "to-${toString(lhs.type)}" or "to-${toString(rhs.type)}" in order to compare two values of the same type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.