Predict Conditional Type Output
Predict Output Medium
Question
What does this code print?
Code
type IsString<T> = T extends string ? "yes" : "no";
const a: IsString<string> = "yes";
const b: IsString<number> = "no";
console.log(a);
console.log(b);
Hint
Conditional types resolve based on whether T extends the condition.
Explanation
IsString<string> resolves to "yes" because string extends string. IsString<number> resolves to "no" because number does not extend string. The variables a and b are assigned accordingly. Output: yes and no.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.