TypeScript · Junior · Question 65 of 75

What's the result type of user?.address?.city if city: string?

Explanation

Optional chaining stops at the first null/undefined and returns undefined, so the result type includes it.

Further reading

Problem with a question

TypeScript · Junior · question 65

Test yourself

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

Take this quiz