Question · Vue.js course · Module 15: TypeScript & Nuxt

Optional Prop in TypeScript

How do you mark a prop as optional in a TypeScript interface?

Answer options

  • By adding @optional before the name
  • By using the Optional() decorator
  • By adding a ? after the property name
  • By placing the prop in an optional[] array

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