简体   繁体   English

Eslint 干扰 Typescript 类型声明

[英]Eslint interfere to Typescript type declaration

在此处输入图像描述

Hey, that's the code I am working with.嘿,这就是我正在使用的代码。

When I am declaring a type this error is shown.当我声明一个类型时,会显示此错误。

So Eslint thinks that I have to use this var and, instead I am returning void.所以 Eslint 认为我必须使用这个 var,而是返回 void。

To use使用
// eslint-disable-line // eslint-disable-line
comment is not an option because I want to avoid unnecessary comments.评论不是一个选项,因为我想避免不必要的评论。 Also I don't want to set it in Eslint configuration.另外我不想在 Eslint 配置中设置它。

How should I overcome this issue?我应该如何克服这个问题? Thanks!谢谢!

So I found a way to solve this issue.所以我找到了解决这个问题的方法。 My mistake was to think that there is only the way to disable all unused vars, but appears that there is a way to disable only args on type declaration.我的错误是认为只有禁用所有未使用的变量的方法,但似乎有一种方法可以在类型声明中仅禁用 args。

To disable only args you have to go to.eslintrc file and add rule: "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],要仅禁用 args,您必须将 go 到 .eslintrc 文件并添加规则: “@typescript-eslint/no-unused-vars”:[“error”,{“args”:“none”}],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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