Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!