繁体   English   中英

即使使用了变量,也会出现 @typescript-eslint/no-unused-vars 警告

[英]Getting @typescript-eslint/no-unused-vars warning occurs even though the variable is used

即使使用了变量,我也会不断收到@typescript-eslint/no-unused-vars 警告。

在此处输入图像描述 即使我使用上图中的变量,我也会收到警告。 我想知道为什么会出现这些警告。

我正在使用 @typescript-eslint/eslint-plugin 和 @typescript-eslint/parser 的 5.0.0 版,以及 Typescript 4.3.5 版。 (使用 Visual Studio 代码编辑器)

另外,我的 tsconfig.json 如下。

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  },
  "typescript.preferences.importModuleSpecifier": "relative"
}

可以通过添加“包含”属性来解决该错误。

include指定要包含在程序中的文件名或模式数组。 这些文件名相对于包含 tsconfig.json 文件的目录进行解析。

{
  "include": ["src/**/*", "tests/**/*"]
}

其中包括:

├── scripts                ⨯
│   ├── lint.ts            ⨯
│   ├── update_deps.ts     ⨯
│   └── utils.ts           ⨯
├── src                    ✓
│   ├── client             ✓
│   │    ├── index.ts      ✓
│   │    └── utils.ts      ✓
│   ├── server             ✓
│   │    └── index.ts      ✓
├── tests                  ✓
│   ├── app.test.ts        ✓
│   ├── utils.ts           ✓
│   └── tests.d.ts         ✓
├── package.json
├── tsconfig.json
└── yarn.lock

参考

暂无
暂无

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

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