Skip to content
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

Better "always true/false" errors #25251

Merged
merged 6 commits into from
Jun 28, 2018
Merged

Conversation

DanielRosenwasser
Copy link
Member

Fixes #25245

@s-ve
Copy link

s-ve commented Jun 27, 2018

@DanielRosenwasser

The types of these values indicates that this condition will always be...

Shoudn't it be "indicate" ? (without the "s")

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indicate*

@DanielRosenwasser
Copy link
Member Author

Thanks for indicating that typo.

@DanielRosenwasser DanielRosenwasser merged commit 950593b into master Jun 28, 2018
@DanielRosenwasser DanielRosenwasser deleted the betterAlwaysTrueFalseErrors branch June 28, 2018 04:57
Copy link
Contributor

@mihailik mihailik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human friendlier messages, please.

@@ -1252,6 +1252,10 @@
"category": "Error",
"code": 2366
},
"The types of these values indicate that this condition will always be '{0}'.": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If those are statically known primitive types, can we include actual values in error message? Like:

"These values are known to be '{0}' and '{1}', rendering this condition always '{2}'."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out #25311

@@ -235,7 +238,8 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator
(() => x + y + v);
if (x == 1) {
~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'.
!!! error TS2367: The types of these values indicate that this condition will always be 'false'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are known to be '0' and '1', rendering this condition always 'false'.
^^^^ how much smoother to comprehend and fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants