'TypeScript Disallow Unecessary optional chain expression
Is there an es lint rule or typescript config to disallow the following ?
let s: string;
s = 'a';
s?.toLocaleLowerCase();
In my opinion, s is not nullable so no need to do optional chain assertion, it just confuses other developers
Solution 1:[1]
The typescript-eslint/no-unnecessary-condition
rule does this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | emlai |