• Sound mode S-08, pre-alpha
  • Design record 0007, Accepted

TSR0801

Definite assignment assertion on '{0}' is not allowed in sound mode. Initialise it in its declaration or the constructor.

A definite assignment assertion ('field!: T' or 'let x!: T') is used in a sound file. Initialise the value or make its type include undefined.

Rule S-08: Fields are initialised before `this` escapes (level: sound). Reported by ts-r-check and ts-r-lsp in files that opt in to sound mode. See Sound mode.

What it means

field!: T and let x!: T tell the checker a value is assigned before use without proving it. Sound files don't allow them (nor declare field redeclarations whose type differs from the inherited one). It's reported at the !.

Example

Spec case from design record 0007 (checked by the record's case harness, not by this site's build)
// A local asserted to be assigned before use.
let count!: number; // @expect TSR0801
function init(): void {
  count = 1;
}
init();
export const c: number = count;

How to fix

  • Initialise the field in its declaration or assign it in the constructor.
  • Or make the type T | undefined and handle the missing case.
  • Fields set from outside by a framework (dependency injection, decorators) need a // @ts-r-unsafe S-08: <reason> hatch per field, or the file kept at strict.

Sound mode is defined in design record 0007 (accepted 2026-10-15).