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

TSR0703

Assertion '{0}' is not proved: the function can return normally with '{1}' of type '{2}'.

An assertion function ('asserts x is T') can return normally when x isn't T. Throw on every path that doesn't prove it.

Rule S-07: Type guards must be proved (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

For asserts x is T, the parameter's flow type at every normal return must be assignable to T; for asserts x, it must be narrowed to truthy. An assertion function that logs instead of throwing lets callers continue with the wrong type. It's reported at the assertion in the signature.

Example

Spec case from design record 0007 (checked by the record's case harness, not by this site's build)
// An assertion function that can return normally with a non-number.
function assertNumber(x: unknown): asserts x is number { // @expect TSR0703
  if (typeof x !== "number") console.warn("not a number");
}
const v: unknown = "a";
assertNumber(v);
export const n: number = v;

How to fix

  • Throw on every path where the condition fails.
  • Or use assert<T>(x) from @ts-r.dev/guard, which is generated from the type.

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