mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-25 05:29:07 -05:00
Improve (and actually use) "always truthy promise" error (#43023)
* Modify error message and actually use the error message. * Accepted baselines.
This commit is contained in:
committed by
GitHub
parent
11097c622c
commit
a3d207a905
@@ -35248,8 +35248,8 @@ namespace ts {
|
||||
errorAndMaybeSuggestAwait(
|
||||
condExpr,
|
||||
/*maybeMissingAwait*/ true,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap,
|
||||
"true", getTypeNameForErrorDisplay(type), "false");
|
||||
Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined,
|
||||
getTypeNameForErrorDisplay(type));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35282,7 +35282,7 @@ namespace ts {
|
||||
const isUsed = isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
||||
|| body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
||||
if (!isUsed) {
|
||||
error(location, Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
||||
error(location, Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3168,7 +3168,7 @@
|
||||
"category": "Error",
|
||||
"code": 2773
|
||||
},
|
||||
"This condition will always return true since the function is always defined. Did you mean to call it instead?": {
|
||||
"This condition will always return true since this function appears to always be defined. Did you mean to call it instead?": {
|
||||
"category": "Error",
|
||||
"code": 2774
|
||||
},
|
||||
@@ -3276,7 +3276,7 @@
|
||||
"category": "Error",
|
||||
"code": 2800
|
||||
},
|
||||
"This condition will always return true since the Promise is always truthy.": {
|
||||
"This condition will always return true since this '{0}' appears to always be defined.": {
|
||||
"category": "Error",
|
||||
"code": 2801
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace ts.codefix {
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_type_1.code,
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code,
|
||||
Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code,
|
||||
Diagnostics.Type_0_is_not_an_array_type.code,
|
||||
Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
|
||||
Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.codefix {
|
||||
const fixId = "fixMissingCallParentheses";
|
||||
const errorCodes = [
|
||||
Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code,
|
||||
Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code,
|
||||
];
|
||||
|
||||
registerCodeFix({
|
||||
|
||||
Reference in New Issue
Block a user