Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
Missing return Type on Function in Vue 3 with Typescript

My code looks like this,

    <template>
      <div>        
        <ul v-if="list.length !== 0">
          {{
            list
          }}
        </ul>
      </div>
    </template>
    <script>
    export default {
      props: {
        
        list: {
          type: Array,
          default: () => {
            return []
          },
        },
        
      },
    }
    </script>

Am I missing something, because I am getting error on this line:

Error screenshot

I also tried solution from this page, but nothing works.

Vue 2 - How to set default type of array in props

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

This is not an error, but a warning that the anonymous function should indicate a return type. Your IDE shows the name of the check, and searching for it leads to a page with good examples.

The warning should be fixed like this:

list: {
  type: Array,
  default: ():Array => {
    return []
  },
},
about 4 years ago · Juan Pablo Isaza Denunciar

0

As error said, you are missing function return type. You defined prop type, but not function return type.

It should look like this (in place of any you should also specify type):

export default {
  props: {
    list: {
      type: Array,
      default: () : Array<any> => {
        return []
      },
    },
  },
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

As a general hint I would suggest that if you are using Vue 3 + Typescript you should take advantage of the defineComponent function to wrap your component options object as documented here: https://v3.vuejs.org/guide/typescript-support.html#defining-vue-components. If you are using the recommended linting settings (and your IDE is working correctly) the problem should be solved

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda