What is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information."? I did some basic googling but I'm not clear on what this means or its implications.
Update! Since this question was asked, the --type-check
flag has been deprecated so you should be able use:
tslint --project tsconfig.json src/**/**.ts
Original answer below.
I believe that this means you can't enable the no-use-before-declare
rule unless you run with the --type-check
and the --project
flags. It must depend on something that happens when those flags are passed in order to determine rule violations.
tslint --type-check --project tslint.json src/**/**.ts
The rule is discouraged, since modern TypeScript do not use it and is slow to compute. Acording to 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.
If you see this warning in VSCode, just delete this rule from tslint.json
, as the README file in vscode-tslint
plugin says:
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.
With TSLint v5.10.0 and above, you need to point TSLint to your TypeScript configuration file. You can do that by using the --project
flag:
tslint --project tsconfig.json --config tslint.json \"src/**/*.ts\"
Be careful, because it's easy to mix up tsconfig.json
and tslint.json
as some users already experienced.
All TSLint CLI options are documented here. The usage of --type-check
is not needed anymore as it got deprecated in TSLint v5.8.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With