Question presented to candidate:
"Walk me through the basic types in TypeScript. Which ones map to JavaScript values, and what are the special ones like any, unknown, void and never for?"
What a strong answer should cover:
- The seven primitives, lowercase:
string,number,bigint,boolean,symbol,null,undefined(and whyStringis the wrong type) - Arrays (
number[]/Array<number>), tuples ([string, number]) and object types with optional properties - The special types:
anydisables checking,unknownmust be narrowed,voidmeans no useful return,nevermeans no possible value unknownas the top type andneveras the bottom type, withanyoutside the ordering- Classic traps:
{}accepts5,typeof nullis"object",bigintdoes not mix withnumber, and types are erased at run time
Code / implementation expected: Optional β a few annotated declarations and one rejected assignment.