mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00: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:
@@ -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({
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(2,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(18,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(36,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(50,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(66,13): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(76,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(2,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(18,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(36,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(50,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(66,13): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(76,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
|
||||
==== tests/cases/compiler/truthinessCallExpressionCoercion.ts (7 errors) ====
|
||||
function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) {
|
||||
if (required) { // error
|
||||
~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
if (optional) { // ok
|
||||
@@ -29,7 +29,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
|
||||
if (test) { // error
|
||||
~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
console.log('test');
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
|
||||
if (test) { // error
|
||||
~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
[() => null].forEach(test => {
|
||||
test();
|
||||
});
|
||||
@@ -65,7 +65,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
|
||||
if (x.foo.bar) { // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
if (x.foo.bar) { // ok
|
||||
@@ -83,7 +83,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
test() {
|
||||
if (this.isUser) { // error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
if (this.maybeIsUser) { // ok
|
||||
@@ -95,7 +95,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
function A(stats: StatsBase<any>) {
|
||||
if (stats.isDirectory) { // err
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
console.log(`[Directory] ${stats.ctime}`)
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion.ts(82,9): error TS2774: Th
|
||||
function B(a: Nested, b: Nested) {
|
||||
if (a.stats.isDirectory) { // err
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
b.stats.isDirectory();
|
||||
}
|
||||
if (a.stats.isDirectory) { // ok
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(3,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(19,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(33,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(46,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(3,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(19,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(33,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(46,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
|
||||
==== tests/cases/compiler/truthinessCallExpressionCoercion1.ts (5 errors) ====
|
||||
@@ -10,7 +10,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T
|
||||
// error
|
||||
required ? console.log('required') : undefined;
|
||||
~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
optional ? console.log('optional') : undefined;
|
||||
@@ -28,7 +28,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T
|
||||
// error
|
||||
test ? console.log('test') : undefined;
|
||||
~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
test ? console.log(test) : undefined;
|
||||
@@ -44,7 +44,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T
|
||||
// error
|
||||
test
|
||||
~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
? [() => null].forEach(test => { test() })
|
||||
: undefined;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T
|
||||
// error
|
||||
x.foo.bar ? console.log('x.foo.bar') : undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
x.foo.bar ? x.foo.bar : undefined;
|
||||
@@ -91,7 +91,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(76,9): error TS2774: T
|
||||
// error
|
||||
this.isUser ? console.log('this.isUser') : undefined;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
this.maybeIsUser ? console.log('this.maybeIsUser') : undefined;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(11,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(14,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(41,18): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(44,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(48,11): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(65,46): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(76,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(79,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(99,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(109,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(11,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(14,10): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(41,18): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(44,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(48,11): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(65,46): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(76,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(79,10): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(99,5): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(109,9): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
|
||||
==== tests/cases/compiler/truthinessCallExpressionCoercion2.ts (11 errors) ====
|
||||
@@ -24,12 +24,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
// error
|
||||
required1 && console.log('required');
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// error
|
||||
1 && required1 && console.log('required');
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
required1 && required1();
|
||||
@@ -58,18 +58,18 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
// error
|
||||
required1 && required2 && required1() && console.log('foo');
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// error
|
||||
if (required1 && b) {
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
// error
|
||||
if (((required1 && b))) {
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
// ok
|
||||
@@ -88,7 +88,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
typeof window !== 'undefined' && window.console &&
|
||||
((window.console as any).firebug || (window.console.exception && window.console.table));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
function checksPropertyAccess() {
|
||||
@@ -101,12 +101,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
// error
|
||||
x.foo.bar && console.log('x.foo.bar');
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// error
|
||||
1 && x.foo.bar && console.log('x.foo.bar');
|
||||
~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
x.foo.bar && x.foo.bar();
|
||||
@@ -128,7 +128,7 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
// error
|
||||
x1.a.b.c && x2.a.b.c();
|
||||
~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
}
|
||||
|
||||
class Foo {
|
||||
@@ -140,12 +140,12 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(112,14): error TS2774:
|
||||
// error
|
||||
this.required && console.log('required');
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// error
|
||||
1 && this.required && console.log('required');
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
|
||||
!!! error TS2774: This condition will always return true since this function appears to always be defined. Did you mean to call it instead?
|
||||
|
||||
// ok
|
||||
this.required && this.required();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/truthinessPromiseCoercion.ts(5,9): error TS2367: This condition will always return 'true' since the types 'Promise<number>' and 'false' have no overlap.
|
||||
tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2367: This condition will always return 'true' since the types 'Promise<number>' and 'false' have no overlap.
|
||||
tests/cases/compiler/truthinessPromiseCoercion.ts(5,9): error TS2801: This condition will always return true since this 'Promise<number>' appears to always be defined.
|
||||
tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2801: This condition will always return true since this 'Promise<number>' appears to always be defined.
|
||||
|
||||
|
||||
==== tests/cases/compiler/truthinessPromiseCoercion.ts (2 errors) ====
|
||||
@@ -9,14 +9,14 @@ tests/cases/compiler/truthinessPromiseCoercion.ts(9,5): error TS2367: This condi
|
||||
async function f() {
|
||||
if (p) {} // err
|
||||
~
|
||||
!!! error TS2367: This condition will always return 'true' since the types 'Promise<number>' and 'false' have no overlap.
|
||||
!!! error TS2801: This condition will always return true since this 'Promise<number>' appears to always be defined.
|
||||
!!! related TS2773 tests/cases/compiler/truthinessPromiseCoercion.ts:5:9: Did you forget to use 'await'?
|
||||
if (!!p) {} // no err
|
||||
if (p2) {} // no err
|
||||
|
||||
p ? f.arguments : f.arguments;
|
||||
~
|
||||
!!! error TS2367: This condition will always return 'true' since the types 'Promise<number>' and 'false' have no overlap.
|
||||
!!! error TS2801: This condition will always return true since this 'Promise<number>' appears to always be defined.
|
||||
!!! related TS2773 tests/cases/compiler/truthinessPromiseCoercion.ts:9:5: Did you forget to use 'await'?
|
||||
!!p ? f.arguments : f.arguments;
|
||||
p2 ? f.arguments : f.arguments;
|
||||
|
||||
Reference in New Issue
Block a user