Vue · Senior · Question 68 of 75

How do you type a complex prop in the Options API?

props: {
  user: { type: Object as PropType<User>, required: true },
}

Explanation

Runtime type checks only the constructor (Object); PropType gives TypeScript the exact shape.

Further reading

Problem with a question

Vue · Senior · question 68

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz