When you want a component to accept any type of prop but with certain constraints, you can make use of TypeScript's ________.

  • any
  • generic
  • union
  • unknown
TypeScript's unknown type is used when you want a component to accept any type of prop but with certain constraints or type checking. It's more restrictive than any as you must perform type assertion or type checking before using values of type unknown. It provides better type safety.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *