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

Type Inference with ref

What happens when we write const count = ref(0) without explicit typing?

Answer options

  • TypeScript will throw an error - the type must be specified explicitly
  • The variable will be typed as ref<any>
  • The variable will be typed as ref<string>
  • TypeScript automatically infers the type as ref<number>

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