Complete the code to define a recursive generic type for a nested array.
type NestedArray<T> = T | Array<[1]>;The type NestedArray is recursive because it refers to itself inside the array definition, allowing nested arrays of any depth.
Complete the code to define a recursive generic type for a tree node with children.
type TreeNode<T> = { value: T; children?: Array<[1]> };The TreeNode type is recursive because the children property is an array of TreeNode itself, allowing nested tree structures.
Fix the error in the recursive generic type for a linked list node.
type LinkedList<T> = { value: T; next: [1] | null };The next property should be either another LinkedList node or null, making the type recursive.
Fill both blanks to define a recursive generic type for a JSON value.
type JSONValue = string | number | boolean | null | { [key: string]: [1] } | Array<[2]>;The JSONValue type is recursive because objects and arrays can contain other JSON values, including nested objects and arrays.
Fill all three blanks to define a recursive generic type for a nested dictionary with string keys.
type NestedDict<T> = { [key: string]: T | [1]<T> | Array<[2]<T>> }; function processDict<T>(dict: [3]<T>) { /* ... */ }The NestedDict type is recursive because dictionary values can be either the base type T, another nested dictionary, or an array of nested dictionaries. The function parameter uses the same recursive type.