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

只谈情不闲聊 提交于 2020-01-24 00:59:13

问题


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?


回答1:


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.




回答2:


In your case, it is the IDE rather than the TypeScript language or compiler that you need to work on.

If your IDE allows you to set the level of warnings, you can tell it to make these informational. Otherwise, you'll need to flip/flop by switching on noImplicitAny while you are working on fixing your older code and the switching it back off again when you feel you have got far enough.




回答3:


you can either enable noImplicitAny as true, or strict as true (would enable noImplicitAny and several other rules), in tsconfig.json.



来源:https://stackoverflow.com/questions/42987268/is-there-any-way-to-get-warnings-not-errors-for-noimplicitany-noncompliance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!