quick-lint-js

Find bugs in JavaScript programs.

E0236: assignment-asserted field must have a type annotation

In TypeScript, ! after a field name indicates a definite assignment assertion. Definite-assignment-asserted fields must have a type annotation. It is a syntax error to write ! on a field without any type annotation:

class AccountBuilder {
  name!;
  address!;

  setName(value: string) {
    this.name = value;
    return this;
  }

  setAddress(value: Address) {
    this.address = value;
    return this;
  }
}

To fix this error, write a type annotation:

class AccountBuilder {
  name!: string;
  address!: Address;

  setName(value: string) {
    this.name = value;
    return this;
  }

  setAddress(value: Address) {
    this.address = value;
    return this;
  }
}

Alternatively, remove the !:

class AccountBuilder {
  name;
  address;

  setName(value: string) {
    this.name = value;
    return this;
  }

  setAddress(value: Address) {
    this.address = value;
    return this;
  }
}

Introduced in quick-lint-js version 2.6.0.

Documentation for other errors