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

211
Views
Vue 3 with TypeScript cannot read properties

I have some problems with Vue 3 and TypeScript. I had one property 'user' that was a string, and I returned object from backend, so ofc it broke, I changed the property type to object but I'm still receiving error like:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'email')

This is how I'm calling it in front.

{{ item.user.email }}

It's actually in v-for, real property is items (array ofc)

So in props it was String, and I changed it to object, like so:

 props: {
    user: {
      type: Object,
      default: undefined
    },

And I have transformer like:

const  gTransformer = (data: GResponse[]): CARD[]  => {
      console.info(data)
      return data.map((element, index): CARD => ({
          id: element.id,
          status: element.status,
          created_at: moment(element.created_at).toDate(),
          updated_at: moment(element.updated_at).toDate(),
          user: element.user
        })
      )

}

And this is how GResponse interface looks like:

export interface GResponse {
  id: number;
  status: number;
  user: any;
  created_at: string,
  updated_at: string
}

and CARD interface is like:

export interface GiftCard {
  id: number;
  status: SomeEnum,
  user: any;
  created_at: Date,
  updated_at: Date
}

What am I doing wrong here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Define your prop types for TypeScript in Vue3 Options API like this: source

import { PropType } from 'vue'
...
props: {
  user: undefined as PropType<Object | undefined>
},
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!