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

TSR1205

Overload '{0}' is not satisfied by its implementation: called through it, the body can return '{1}', which is not assignable to '{2}'.

Called through one of its overloads, a function's body can return a value that overload's return type doesn't allow. Fix the branch or the overload.

Rule S-12: No suppression comments, unchecked overload implementations or global augmentation (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

TypeScript checks an overloaded function's body only against its implementation signature, not against each overload, so an overload can promise a return type the body never produces for its arguments. In sound files the body is checked once per overload signature: with the parameters typed as that overload declares them, every return the body can reach, and a reachable end as undefined, must be assignable to the overload's return type. {0} is the overload, {1} what the body returns through it, and {2} the overload's return type. It's reported at the return.

Branches the overload can't reach are skipped: if a parameter narrows to never on a path (a typeof x === "string" test under an overload that takes a number), returns on that path aren't checked against it. Overloads without an implementation (interfaces, .d.ts) aren't checked.

Example

Spec case from design record 0007 (checked by the record's case harness, not by this site's build)
// Called through the second overload, the body returns the number it was given, not a string.
function first(value: string): string;
function first(value: number): string;
function first(value: string | number): string | number {
  return value; // @expect TSR1205
}
export const n: string = first(7);

How to fix

  • Fix the branch so it returns the overload's type for that overload's arguments (here String(value)).
  • Or correct the overload's return type if the body is right (function first(value: number): number).
  • Or narrow the parameter before returning, so each overload only reaches the branch meant for it.

This code replaced TSR1203, which banned overload implementations in sound files; TSR1203 is retired. Sound mode is defined in design record 0007 (accepted 2026-10-15).