简体   繁体   中英

TSLint: Warning: The 'no-use-before-declare' rule requires type checking

I'm working on a medium sized Angular 4 project which uses TSLint.

Every time I run the lint command with npm run lint (which uses ng lint ) I see a warning in the command line:

Warning: The 'no-use-before-declare' rule requires type checking

I've tried to enable type-checking by adding the --type-check and --project path/to/the/tsconfig.json file which is apparently " all you need to do "™, but whatever I do, the warning is still shown in the console (as if the flags are not having any effect).

There are no lint issues in the project, regardless of whether I use the --type-check and --project flags or not.

Is type-checking being enabled? Should the warning go away?

Edit

The problem is with passing the flags from the command-line to the ng lint command:

If I run the command on the command line like this:

npm run lint --type-check --project tsconfig.json

Then I still see the warning on the command line. If I update the command in the package.json to this:

"lint": "ng lint --type-check --project tsconfig.json",

Then the warning message is not shown in the console, and I get a couple of extra lints.

The problem was only with passing flags from command line to the ng lint command. I fixed it using this command from the command line:

npm run lint -- --type-check

Just needed the extra -- to pass the flag through correctly

A quick update to this answer:

TSlint outputs now --type-check is deprecated. You only need --project to enable rules which need type information. --type-check is deprecated. You only need --project to enable rules which need type information. when using --type-check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM