This snippet compiles without any warning:
const result: string[] = gimmeResult(); // returns an array type
if (!result) {
// code
}
And I'd argue it's almost always a masked bug (the programmer did not realise the return value was an array).
Would it be sensible to emit some sort of a warning?
and if (result) { .. is not allowed either?
Duplicate #9041 ?
Or #14114
@mhegazy Yeah, good point. :-) I would say any array -> boolean coercion is a code smell and most probably a bug.
@RyanCavanaugh Thanks. Man, you must have a really good memory. :-D
I just keep all the issue numbers scrawled on a scrap of paper near my desk :wink:
@RyanCavanaugh the hyperspace In | n ∈ Z ≥ 14638 over the field of Typescript issues reduced to a single flat physical object 😲
@RyanCavanaugh Man, you must have a really large desk. :)
At work:

...sorry couldn't help it, I'll stop spamming now :-)
Most helpful comment
At work:
...sorry couldn't help it, I'll stop spamming now :-)