Advanced
TypeScript
Q95 / 100
How does TypeScript handle circular type references, e.g. "type Json = string | number | boolean | null | Json[] | { [key: string]: Json }"?
Correct! Well done.
Incorrect.
The correct answer is B) TypeScript supports lazily-evaluated recursive type aliases for object and array types, allowing such self-referential definitions
B
Correct Answer
TypeScript supports lazily-evaluated recursive type aliases for object and array types, allowing such self-referential definitions
Explanation
TypeScript allows recursive type aliases as long as the recursive reference occurs within an object or array type (not directly in a union at the top level in a way that creates infinite expansion), enabling structures like JSON types.
Progress
95/100