Question · JavaScript and TypeScript course · Module 6: TypeScript Basics

Optional Interface Properties

How do you mark an interface property as optional in TypeScript?

Answer options

  • Using the optional keyword
  • Adding ? after the property name (e.g., name?: string)
  • Adding | undefined to the type
  • Wrapping the type in square brackets

You can check the correct answer by solving this task in the CodeWorlds game.