Is there a typescript-eslint rule that alerts you when you use a method as a boolean?
问题 In Javascript, I sometimes accidentally write: if (obj.method) { // <-- bad ... } instead of if (obj.method()) { // <-- good ... } Given that typescript-eslint is typeaware, is there a rule that detects this usage? I would say that 99/100 times, I am not trying to use the method as a boolean. 回答1: If you turn on typescript's strictNullChecks compiler option (or the catch-all strict compiler option), TS will do this specific check for you automatically! Example: https://www.typescriptlang.org