What does the ‘as’ keyword do in TypeScript?

TypeScript Associate Medium

TypeScript Associate — Medium

What does the ‘as’ keyword do in TypeScript?

Key points

  • Type assertion with 'as' is a way to override TypeScript's type inference
  • It is used to specify a more specific type for a variable
  • Helps avoid type errors during compilation

Ready to go further?

Related questions