简体   繁体   English

WebStorm 中的所有导入在 TypeScript 后端项目中显示为未使用

[英]All imports in WebStorm shown as unused at TypeScript backend project

https://i.stack.imgur.com/J0yZw.png This is how it looks for all files with .ts . https://i.stack.imgur.com/J0yZw.png这就是它查找所有带有.ts的文件的方式。 And in .tsx files it also doesn't work..tsx文件中它也不起作用。

Other projects in WebStorm work correct but they're written in .js and .jsx only. WebStorm 中的其他项目工作正常,但它们仅用.js.jsx编写。

Also I've tried reinstall WebStorm twice and set all to defaults, that doesn't help at all.我也试过两次重新安装 WebStorm 并将所有设置为默认值,这根本没有帮助。

Do you have a.eslintrc.js file?你有 a.eslintrc.js 文件吗? If not, try adding one so that Webstorm understands what is going on:如果没有,请尝试添加一个以便 Webstorm 了解发生了什么:

module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
  project: 'tsconfig.json',
  sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
  'plugin:@typescript-eslint/recommended',
  'prettier/@typescript-eslint',
  'plugin:prettier/recommended',
],
root: true,
env: {
  node: true,
  jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
  '@typescript-eslint/interface-name-prefix': 'off',
  '@typescript-eslint/explicit-function-return-type': 'off',
  '@typescript-eslint/explicit-module-boundary-types': 'off',
  '@typescript-eslint/no-explicit-any': 'off',
},
};

Also make sure you have typescript enabled in preferences as well (see my image).还要确保您在首选项中也启用了 typescript(请参见我的图片)。 在此处输入图像描述

Good luck!祝你好运!

One more set to defaults helps me.再设置为默认值对我有帮助。 Ty all全部

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

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