English 中文(简体)
正式决定错误:作为ESLint决心者的无效接口的类型
原标题:Resolve Error: typescript with invalid interface loaded as resolver ESLint

I m在我的项目中拥有ESLint,并出现错误 决定 编号: 无效接口的类型,装上决心器: 进口-无限制-第, 添加以下规则:<代码> 进口/无限制-第

“Error”/

tsconfig.json

{
    "include": [
        "./src/**/*",
        "./generated/**/*"
    ],
    "compilerOptions": {
        "resolveJsonModule": true,
        "target": "es5",
        "module": "esnext",
        "moduleResolution": "node",
        "lib": [
            "dom",
            "es6"
        ],
        "downlevelIteration": true,
        "jsx": "react",
        "declaration": false,
        "sourceMap": true,
        "baseUrl": "src",
        "outDir": "./dist/js",
        "paths": {
            "@generated/*": ["../generated/*"],
            "api": ["lib/api"],
            "api/*": ["lib/api/*"],
            "asset/*": ["lib/asset/*"],
            "base/*": ["lib/base/*"]
        },
        // Rules
        "noImplicitAny": false,
        "strictNullChecks": true,
        "noImplicitThis": true,
        "alwaysStrict": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "forceConsistentCasingInFileNames": true,
        "esModuleInterop": true,
        "isolatedModules": true
    }
}

.eslint.json

module.exports = {
    env: {
        browser: true
    },
    settings: {
        "import/parsers": {
            "@typescript-eslint/parser": [".ts", ".tsx"]
        },
        "import/resolver": {
            "typescript": {
                paths: "./tsconfig.json",
                alwaysTryTypes: true
            }
        },
    },
    parser: "@typescript-eslint/parser",
    parserOptions: {
        tsconfigRootDir: ".",
        sourceType: "module",
        project: "./tsconfig.json"
    },
    extends: [
        "plugin:import/recommended",
        "plugin:import/typescript"
    ],
    plugins: [
        "@typescript-eslint",
        "import"
    ],
    overrides: [
        {
            files: [
                "src/_migration/**"
            ],
            rules: {
                "import/no-restricted-paths": [
                    "error",
                    {
                        basePath: "./src",
                        zones: [
                            { target: "./_migration", from: "./", except: [ ./_migration ] }
                        ],
                    },
                ]
            }
        },
    ],
    rules: {
        "import/no-unresolved": "off",
        "@typescript-eslint/typedef": [
            "error",
            {
                parameter: true
            }
        ]
    }
};
问题回答

这对我来说似乎只是trick。

npm install -D eslint-import-resolver-typescript

我不想删除<代码> 包装-锁.json。 我从经验中知道,这样做给我目前的项目造成问题。

For me, it was just enough to restart the eslint server. On Visual Studio Code, you can do it with cmd+p and start typing:

>eslint: restart eslint server

加入<代码>。 这对我来说已经解决了。

"settings": {
  "import/resolver": {
    "node": {
      "extensions": [".js", ".jsx", ".ts", ".tsx"]
    }
  }
}

我将pnpm作为一揽子管理人员。 或许可以在<代码>node_modules上用正文安装一些包裹。 这是因为甲型六氯环己烷依赖性。 但pnpm解决了这一问题。 因此,我安装了<条码>slint-import-resolver-type-script依附和重新启用slint服务器,然后运行良好。

感谢的答复。 Joel Sullivan :





相关问题
store data in memory with nestjs

I am trying to persist some data in my nestjs server so I can then use that data in my client app through http requests. I have created a products.service.ts file with the function getAllData() that ...

React Hook Form Error on custom Input component

I am having a problem when I use react hook form + zod in my application, in short the inputs never change value and I get the following error in the console: Warning: Function components cannot be ...

Updatable promises using proxy in JavaScript

EDIT: I ve updated this question, and the old question is moved here. A POC can be found on this jsfiddle or the snippet below GOAL: The goal here is to make or rather simulate a promise that can be ...

热门标签