8
votes

I have upgraded Eslint from 7.7.0 to 7.10.0 and @types/node from 14.6.0 to 14.11.2. The application tsconfig.json defines types: ["node"] and typescript is version 4.0.3. Eslint is called with eslint --env node,es2020.

Before the upgrade Eslint never flagged any problem in my code. Now Eslint started complaining that NodeJS is not defined in the following code fragment:

private handleServerErrors(error: NodeJS.ErrnoException): void {
    if(error.code === "EADDRINUSE") {
        . . .

I silence the Eslint error and the compilation succeeded. So seems a problem specific to eslint, not the code.

The same problem happens in another file for namespace JQuery, but I had not yet investigated.

Is there anything I'm missing? Need to add some import? What has changed in eslint/typescript/node?

Thanks for your help! mario

1
Well, If I put all these undefined namespaces in the globals section of eslint.yaml the error goes away. But this seems too gross to be the right solution. Why eslint before has not complained? - SiliconValley
I run into this problem recently, it's very wired. - Huan

1 Answers

1
votes

In my case, @typescript-eslint/parser@4 causes this problem.

Downgrade it to v3 @typescript-eslint/parser@3 to solve the problem.

See: https://github.com/Chatie/eslint-config/issues/45