Search code examples
typescriptwebstorm

WebStorm: Argument type this is not assignable to parameter type ObjectConstructor


When I use the following constructor in TypeScript, I get the error Argument type this is not assignable to parameter type ObjectConstructor. But CLI is not showing the error. The code looks OK to me (syntax). Is this a false error?

export class Store{
  oid: string;
  storeNumber: string;
  address: string;

  public constructor(init?: Partial<Store>) {
    Object.assign(this, init);
  }
}

Solution

  • This has been logged as a WebStorm bug. (Thank you, @lena).

    Until a fix is issued, one could supress the inspection by placing the following comment above the line containing the false positive:

    // noinspection TypeScriptValidateTypes