Complete worked example
typescript
function fail(message: string): never { throw new Error(message); }
function normalize(value: unknown): string {
if (typeof value !== "string") return fail("Text required");
return value.trim();
}- Reasoning
- The failure path cannot return; the remaining path has a checked string.