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

TSR1303

Only Error objects can be thrown in sound mode; '{0}' is not assignable to 'Error'.

A non-Error value is thrown or passed to Promise.reject. Throw an Error instance (or a subclass) instead.

Rule S-13: Checked exceptions (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

Only Error instances may be thrown or passed to Promise.reject in sound files, so catch blocks can rely on message and stack. Re-throwing the catch variable is allowed. It's reported at the thrown or rejected expression.

Example

Spec case from design record 0007 (checked by the record's case harness, not by this site's build)
// Only Error objects may be thrown.
function fail(reason: string): never {
  throw "failed: " + reason; // @expect TSR1303
}
export const n: number = Math.random() > 2 ? fail("x") : 1;

How to fix

  • Throw an Error or a subclass: throw new Error("failed: " + reason).
  • Use Promise.reject(new Error(...)) for rejections.

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