The never type

never is CruftScript's empty type, the type no value can ever have. It is assignable to everything but nothing is assignable to it, and it is the mirror of unknown. You do not write it directly; it appears as the result when a union filters empty or a key set turns out to be empty.

never is CruftScript's empty type: the type that no value can ever have. It is the mirror of the unknown type. Where unknown accepts every value and is assignable to nothing, never accepts no value and is assignable to everything.

let x: string = neverValued    // ok: never is assignable to anything
let y: never = "hi"            // error: string is not assignable to never

If you have used TypeScript, this is the same never. It is the type at the very bottom of the system, and its defining property is that it has no values at all.

The one rule

Because never is inhabited by nothing, a never value can stand in for a value of any type: there is no actual value that could contradict the target, so the assignment is always allowed. The reverse never holds. No ordinary value is assignable to never, because that would require a value the type says cannot exist.

You rarely write never yourself. It shows up as a result the type system produces when a computation lands on "no possibilities left."

Where it comes from

Three common situations produce never:

  • A union filters empty. When every member of a union is removed, what remains is never. The union page describes this simplification: never members are dropped, and an empty union collapses to never.

``fts type T = string | never // string (the never member is dropped) type U = never // never (nothing left) ``

  • A union filters to nothing at the type level. When type-level simplification removes every member of a union, the result is never, as shown above. (Note: case-by-case narrowing in an if/switch does not yet subtract ruled-out cases from the negative branch, so it does not currently leave never in a final branch — see type narrowing.)
  • keyof unknown. An unknown value exposes no keys, so the set of its keys is the empty set, which is never rather than "some string or symbol."

``fts type K = keyof unknown // never ``

Why it works this way

never gives the type system an honest way to say "this cannot happen." A union that has filtered down to nothing, a branch that can never be reached, a key set that is empty: each is a real outcome, and collapsing it to never records that fact instead of inventing a placeholder. The assignable-to-everything rule then makes never usable as a signal. A function whose return type is never never returns normally. The value is that this guarantee is structural, not a convention you have to remember. (Exhaustiveness-to-never from narrowing branches is a natural extension of this idea but is not implemented today; see type narrowing.)

Limitations

  • You cannot produce a never value. No expression yields one, because none can. never is a type you observe as a result, not one you construct.
  • Reaching never unexpectedly usually means something upstream went empty. If a binding you did not intend to be impossible ends up typed never, look for a union that filtered to nothing or a narrowing that excluded every case.