@typescript-eslint/no-unsafe-assignment with conf library

17 views Asked by At

I get this error and @typescript-eslint/no-unsafe-call when I try to instantiate conf

import Conf from 'conf';
const conf = new Conf({ projectName: 'my-proj-name' });

I do not want to disable the rule if there is a sensible way around it.

When I hover over conf i see:

const conf: Conf<Record<string, unknown>>

And over new Conf:

Unsafe assignment of an `any` value.eslint@typescript-eslint/no-unsafe-assignment
Unsafe construction of an any type value.eslint@typescript-eslint/no-unsafe-call
(alias) new Conf<Record<string, unknown>>(partialOptions?: Readonly<Partial<Options<Record<string, unknown>>>> | undefined): Conf<Record<string, unknown>>
import Conf

I use VSCode. My tsconfig:

{
    "compilerOptions": {
      "lib": ["es2023"],
      "module": "Node16", 
      "moduleResolution": "Node16", 
      "target": "ES2020",
      "strict": true,
      "esModuleInterop": true,
      "skipLibCheck": true,
      "forceConsistentCasingInFileNames": true,
      "resolveJsonModule": true,
      "noImplicitAny": true,
      "sourceMap": true,
      "outDir": "dist",
      "baseUrl": ".", 
      "rootDir": ".",
      "paths": {
        "@config/*": ["src/config/*"],
        "@utils/*": ["src/utils/*"],
        "@runners/*": ["src/runners/*"]
      }
    },
    "include": ["src", "eslint.config.js"]
  }
  

In package.json:

  "type": "module",

The conf package has: node_modules/conf/dist/source/types.d.ts and node_modules/conf/dist/source/index.d.ts

I have tried a few variations of type assertions on the instance but since VSCode picks up on the type, I tend to beleive it's eslint not picking up the correct type.

Any leads are apprectiated.

0

There are 0 answers