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

Typing ref with Union

How do you correctly type a ref that can be string or null?

Answer options

  • ref<string | null>(null)
  • ref<nullable<string>>(null)
  • ref<string>(null)
  • ref.nullable<string>()

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