quick-lint-js

Find bugs in JavaScript programs.

E0290: assignment-assertion fields cannot have default values

In TypeScript, ! after a field name indicates a definite assignment assertion. It is a syntax error to initialize such a field:

class Banana {
  skin!: BananaSkin | undefined = undefined;

  peel() {
    this.skin = undefined;
  }
}

To fix this error, remove the !:

class Banana {
  skin: BananaSkin | undefined = undefined;

  peel() {
    this.skin = undefined;
  }
}

Alternatively, remove the initializer:

class Banana {
  skin!: BananaSkin | undefined;

  peel() {
    this.skin = undefined;
  }
}

Documentation for other errors