What does the following conditional type evaluate to? type IsString = T extends string ? true : false; type A = IsString; type B = IsString;

TypeScript Associate Hard

TypeScript Associate — Hard

What does the following conditional type evaluate to? type IsString = T extends string ? true : false; type A = IsString; type B = IsString;

Key points

  • A and B are assigned the same conditional type IsString
  • A evaluates to true because it extends string
  • B is a boolean due to the distribution over the union

Ready to go further?

Related questions