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

computed Inference

Does TypeScript automatically infer the return type of computed?

Answer options

  • No - the type must always be specified explicitly
  • Yes - TypeScript infers the type from the return value
  • Only for simple types (string, number)
  • Only when using computed<T> with an explicit generic

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