Home > OS >  eslint show error on undefined in typescript code
eslint show error on undefined in typescript code

Time:04-22

enter image description here

I have a typescript project, I use @typescript-eslint/parser and @typescript-eslint/eslint-plugin to lint it.

It seems eslint couldn't recognize undefined in my project. The error message is:

Variable 'undefined' implicitly has an 'any' type.ts(7005)

I have searched on the internet but got nothing.

Have you ever got the same problem?

CodePudding user response:

Could you try to add the line below to tsconfig.ts?:

"noImplicitAny": false

CodePudding user response:

I found two ways to resolve it:

  1. npm i @types/node --save-dev
  2. "lib": ["esnext", "DOM"] in tsconfig.json

You don't need to do both of them.

  • Related