Search code examples
typescripttslint

Is there any way to get warnings (not errors) for noImplicitAny noncompliance?


I have a lot of code that I'm porting to Typescript with missing types. For now, I'd like my IDE (WebStorm) to just highlight places that need typing, and I'll slowly get them fixed up.

If tsconfig.json had a warning setting for noImplicitAny, that would be ideal. Another alternative would be a tslint rule, but I don't know if the tslint engine is up to this job.

Does anyone know of a way to achieve this?


Solution

  • Edit:

    As antoine129 pointed out in the comments,there is actually no noImplicitAny eslint rule. I was thinking of no-explicit-any. One approach would be to havenoImplictAny on in the tsconfig and set no-explicit-any: "warn" in the .eslintrc, but you would have to add all the anys first.

    OLD ANSWER (incorrect):

    The Typescript ESLint plugin can do this. Since this question was posted, TSLint has been deprecated in favour of using ESLint with @typescript-eslint/eslint-plugin.

    To get eslint warnings instead of compiler errors, you could turn the noImplicitAny flag off in tsconfig.json, and set noImplicitAny to "warn" in the rules section of your .eslintrc.