Question presented to candidate:
"What is the never type in TypeScript? Where does it show up on its own, and where would you write it deliberately?"
What a strong answer should cover:
neveris the bottom type: the type with no values. It is assignable to every type, and nothing (not evenanyorunknownvalues) is assignable to it- Where it appears by itself: functions that cannot return normally, branches where narrowing has removed every member, impossible intersections like
string & number, and[]inside an object literal (never[]) - Algebra:
T | neverisT; a conditional type maps members toneverto drop them (howExcludeworks); key filtering with mapped types - Deliberate uses: exhaustiveness checks, forbidding a property with
prop?: never - Traps: a distributive conditional over
nevergivesnever, soIsNeverneeds[T] extends [never];nevervsvoidvsunknown
Code / implementation expected: Optional β a few type-level checks, or an exhaustiveness helper.