TypeScript | Advanced Types in TypeScript | Question8

Last Updated :
Discuss
Comments

Which of the following defines a recursive type for a nested object structure?

TypeScript
type NestedObject = {
    value: string;
    children?: NestedObject[];
};


A type with a string value and optional array of NestedObject children.

A type that prevents nested arrays.

A type that enforces all properties to be strings.

A mapped type for optional properties.

Share your thoughts in the comments