the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

TS1090

'{0}' modifier cannot appear on a parameter.

Some modifiers can be added to constructor parameters in order to automatically declare the parameter as an element of the class. If you try to use an invalid modifier, this error will occur:

class A {
  constructor(static param: string) {}
}

Fix: Refactor code to remove modifier.

Replace the modifier with the explicit code you were hoping TypeScript would generate.

class A {
  static param: string = "";

  constructor(param: string) {
    A.param = param;
  }
}