TypeScript · Middle · Question 72 of 75

How do you write a type for any JSON value?

type Json = string | number | boolean | null | Json[] | { [key: string]: Json };

Explanation

Recursive type aliases are allowed when the recursion goes through object or array types.

Further reading

Problem with a question

TypeScript · Middle · question 72

Test yourself

Take the TypeScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz