What does ‘T extends string’ mean in a TypeScript generic constraint?

TypeScript Associate Medium

TypeScript Associate — Medium

What does ‘T extends string’ mean in a TypeScript generic constraint?

Key points

  • 'T extends string' restricts the type T to be assignable to string
  • Only values that are strings or can be converted to strings are allowed
  • This constraint limits the types that can be passed to the generic

Ready to go further?

Related questions