typescript Angular:为什么 tslint 中不允许按位运算符?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47622824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 05:05:31  来源:igfitidea点击:

Angular: Why are bitwise operators not allowed in tslint?

angulartypescripttslint

提问by Mick

We can't use bitwise operators in templates, but why are they not allowed by tslint within TypeScript code?

我们不能在模板中使用按位运算符,但为什么 TypeScript 代码中的 tslint 不允许使用位运算符?

"no-bitwise": true,

回答by Grant Eagon

Bitwise operators are often typos - for example bool1 & bool2 instead of bool1 && bool2. They also can be an indicator of overly clever code which decreases maintainability.

按位运算符通常是错别字 - 例如 bool1 & bool2 而不是 bool1 && bool2。它们也可能表明代码过于聪明,从而降低了可维护性。

https://palantir.github.io/tslint/rules/no-bitwise/

https://palantir.github.io/tslint/rules/no-bitwise/

回答by Sajeetharan

If you look at the Docs

如果你看 Docs

"Bitwise operators are very rare in JavaScript programs"

“按位运算符在 JavaScript 程序中非常少见”

anyhow you can disable the bitwise option to stop the warnings.

无论如何,您可以禁用按位选项来停止警告。