How do you declare a class property `name` of type string in TypeScript?

TypeScript Associate Easy

TypeScript Associate — Easy

How do you declare a class property `name` of type string in TypeScript?

Key points

  • Syntax for declaring class properties in TypeScript is property name followed by a colon and the type
  • Incorrect options use incorrect syntax or do not specify the type correctly
  • TypeScript requires explicit typing for class properties

Ready to go further?

Related questions