TypeScript Types
never — no possible normal value
Never represents an impossible value or a function that cannot complete normally. It can be assigned to other types, but ordinary values cannot be assigned to it. When every member of a discriminated union has been handled, the remaining value may narrow to never. A function returning void is different: it can finish normally. Example output: "enabled". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
function fail(): never { throw new Error("failed"); }Working Example
Example Snippettypescript
function describe(value: "on" | "off"): string { switch (value) { case "on": return "enabled"; case "off": return "disabled"; default: { const unreachable: never = value; return unreachable; } }}console.log(describe("on"));