最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeScript Disallow Unecessary optional chain expression - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question asked May 6, 2022 at 11:00 TSRTSR 20.9k32 gold badges120 silver badges240 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The typescript-eslint/no-unnecessary-condition rule does this.

发布评论

评论列表(0)

  1. 暂无评论