ESlint can't resolve custom types.d.ts
Asked Answered
B

0

6

I have an electron forge project using typescript with some default settings. I added a custom types.d.ts under src/types.d.ts looking like this:

declare module 'mymodule' {
    export namespace Types {
        type MyType = {
            prop: string
        }
    }
}

When I try to import this type, ESlint can't seem to resolve the module. TSC does not complain.

import { Types } from 'mymodule'
^^^ Unable to resolve path to module 'mymodule'. eslint(import/no-unresolved)

My ESlint config:

{
    "env": {
        "browser": true,
        "es6": true,
        "node": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:import/recommended",
        "plugin:import/electron",
        "plugin:import/typescript"
    ],
    "rules": {
        "@typescript-eslint/explicit-module-boundary-types": "off"
    },
    "parser": "@typescript-eslint/parser"
}

How can I my ESlint find my module?

Boulevardier answered 19/8, 2021 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.