tslint: "Warning: The 'no-use-before-declare' rule requires type information" 是什么意思?
what is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information"?
tslint 的含义是什么:"Warning: The 'no-use-before-declare' rule requires type information."?我做了一些基本的谷歌搜索,但我不清楚这意味着什么或它的含义。
更新!由于提出了这个问题,--type-check
标志已被弃用,因此您应该可以使用:
tslint --project tsconfig.json src/**/**.ts
下面是原始答案。
我认为这意味着您无法启用 no-use-before-declare
规则,除非您 运行 带有 --type-check
和 --project
标志。它必须取决于传递这些标志时发生的事情以确定是否违反规则。
tslint --type-check --project tslint.json src/**/**.ts
使用 TSLint v5.10.0 及更高版本,您需要将 TSLint 指向您的 TypeScript configuration 文件。您可以使用 --project
标志来做到这一点:
tslint --project tsconfig.json --config tslint.json \"src/**/*.ts\"
小心,因为有些用户 already experienced 很容易混淆 tsconfig.json
和 tslint.json
。
所有 TSLint CLI 选项都是 documented here. The usage of --type-check
is not needed anymore as it got deprecated in TSLint v5.8.0。
不鼓励使用该规则,因为现代 TypeScript 不使用它并且计算速度很慢。根据 this page:
This rule is primarily useful when using the var keyword since the compiler will automatically detect if a block-scoped let and const variable is used before declaration. Since most modern TypeScript doesn’t use var, this rule is generally discouraged and is kept around for legacy purposes. It is slow to compute, is not enabled in the built-in configuration presets, and should not be used to inform TSLint design decisions.
如果您在 VSCode 中看到此警告,只需从 tslint.json
中删除此规则,如 vscode-tslint
插件中的 README 文件所述:
Since tslint version 5 the rule no-unused-variable requires type information. Rules with type information are currently not supported by vscode-tslint, pls see issue #70. The recommended work around is to enable the TypeScript compiler options noUnusedLocals and noUnusedParameters in your tsconfig.json file.
tslint 的含义是什么:"Warning: The 'no-use-before-declare' rule requires type information."?我做了一些基本的谷歌搜索,但我不清楚这意味着什么或它的含义。
更新!由于提出了这个问题,--type-check
标志已被弃用,因此您应该可以使用:
tslint --project tsconfig.json src/**/**.ts
下面是原始答案。
我认为这意味着您无法启用 no-use-before-declare
规则,除非您 运行 带有 --type-check
和 --project
标志。它必须取决于传递这些标志时发生的事情以确定是否违反规则。
tslint --type-check --project tslint.json src/**/**.ts
使用 TSLint v5.10.0 及更高版本,您需要将 TSLint 指向您的 TypeScript configuration 文件。您可以使用 --project
标志来做到这一点:
tslint --project tsconfig.json --config tslint.json \"src/**/*.ts\"
小心,因为有些用户 already experienced 很容易混淆 tsconfig.json
和 tslint.json
。
所有 TSLint CLI 选项都是 documented here. The usage of --type-check
is not needed anymore as it got deprecated in TSLint v5.8.0。
不鼓励使用该规则,因为现代 TypeScript 不使用它并且计算速度很慢。根据 this page:
This rule is primarily useful when using the var keyword since the compiler will automatically detect if a block-scoped let and const variable is used before declaration. Since most modern TypeScript doesn’t use var, this rule is generally discouraged and is kept around for legacy purposes. It is slow to compute, is not enabled in the built-in configuration presets, and should not be used to inform TSLint design decisions.
如果您在 VSCode 中看到此警告,只需从 tslint.json
中删除此规则,如 vscode-tslint
插件中的 README 文件所述:
Since tslint version 5 the rule no-unused-variable requires type information. Rules with type information are currently not supported by vscode-tslint, pls see issue #70. The recommended work around is to enable the TypeScript compiler options noUnusedLocals and noUnusedParameters in your tsconfig.json file.