4 ms·
TypeScript will produce an error when using a function inside and if stmt without calling it: function f() {} if (f) {} produces: This condition
by emptysea 5y ago
TypeScript will produce an error when using a function inside and if stmt without calling it:
function f() {}
if (f) {}
produces:
This condition will always return true since this function is always defined. Did you mean to call it instead?(2774)
https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABMAFASkQbwL4CgbCIrAY5A https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABMA...
- not2b 5y agoIt seems that a linter tool would catch this even if TypeScript isn't used. In any case even if "get" is used, a coder might accidentally write if (getBooleanProperty) { ... } omitting the parens.