WebStorm thinks Error constructor has zero args

Viewed 641

Running WebStorm 2019.1 with ECMAScript 6 language level.

If I do the following:

new Error('Foobar');

it will not produce any warnings. But if I do the following:

class SomeError extends Error {
  constructor(message) {
    super(message);
  }      
}

Then WebStorm complains on the call to the super constructor, saying Invalid number of arguments, expected 0.

I also tried using spread arguments, such as

constructor(...args) {
  super(...args);
}

This gives the same results - 0 args expected.

Checking the lib.es5.d.ts file, the interfaces for Error look like this:

interface Error {
   name: string;
   message: string;
   stack?: string;
}

interface ErrorConstructor {
   new(message?: string): Error;
   (message?: string): Error;
   readonly prototype: Error;
}

declare var Error: ErrorConstructor;

This looks correct to me. So why does the IDE insist that when extending Error, the super-class constructor must not have any arguments? Sure, I can do this.message = message; instead, but I'm curious as to what's going on. Is this a problem with the IDE, with some of my settings for language level compatibility, or am I stupid?

1 Answers

Known issue, WEB-32758 is fixed in upcoming IDEA 2019.2

Related