TSLint:未使用的 var 关键字 [英] TSLint: Unused var keyword
问题描述
我已经为我的 TypeScript 项目配置了 TSLint,但我不知道警告 forbidden var keyword
是什么意思.这是一个最小的例子,它导致 TSLint 警告:
var x: number = 1;
谢谢.
我正在使用 示例 tslint.json.
表示不允许使用 var 语法声明
var = 1;
这是 Ecmascript 6 规则,其目的是确保您不会意外地在同一作用域中两次重新声明同一个变量,从而无意中赋予它另一个含义.
查看此页面:http://eslint.org/docs/rules/no-var>
I've configured TSLint for my TypeScript project and I don't know what does the warning forbidden var keyword
mean. Here is a minimal example, which results in the TSLint warning:
var x: number = 1;
Thank you.
Edit: I'm using the sample tslint.json.
It means you are not allowed to declare using var syntax
var = 1;
It's an Ecmascript 6 rule, it's purpose would be to ensure you don't accidentally re-declare the same variable twice in the same scope, giving it another meaning unintentionally.
See this page: http://eslint.org/docs/rules/no-var
这篇关于TSLint:未使用的 var 关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!