TypeScript · Middle · Question 6 of 75

What does the conditional type T extends string ? 'text' : 'other' do?

Explanation

Conditional types are a type-level "ternary". Together with infer, they let you extract parts of types. Applied to a union, they distribute over each member (distributive conditional types).

Further reading

Problem with a question

TypeScript · Middle · question 6

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