是否有任何方法可以针对 noImplicitAny 违规获得警告(而非错误)? [英] Is there any way to get warnings (not errors) for noImplicitAny noncompliance?

查看:27
本文介绍了是否有任何方法可以针对 noImplicitAny 违规获得警告(而非错误)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多代码要移植到缺少类型的 Typescript.目前,我希望我的 IDE (WebStorm) 只突出显示需要输入的地方,然后我会慢慢修复它们.

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.

如果 tsconfig.jsonnoImplicitAnywarning 设置,那将是理想的.另一种选择是 tslint 规则,但我不知道 tslint 引擎是否适合这项工作.

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?

推荐答案

正如 antoine129 在评论中指出的,实际上没有 noImplicitAny eslint 规则.我在考虑 no-explicit-any.一种方法是在 tsconfig 中启用 noImplictAny 并在 .eslintrc 中设置 no-explicit-any: "warn",但是您必须先添加所有 any.

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.

旧答案(不正确):

Typescript ESLint 插件可以做这个.自从发布这个问题以来,TSLint 已被弃用,转而使用带有 @typescript-eslint/eslint-plugin 的 ESLint.

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.

要获得 eslint 警告而不是编译器错误,您可以关闭 tsconfig.json 中的 noImplicitAny 标志,并将 noImplicitAny 设置为 "warn".eslintrc 的规则部分.

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.

这篇关于是否有任何方法可以针对 noImplicitAny 违规获得警告(而非错误)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆