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

198
Views
Why am I getting a Typescript type error for a Date field?

I have the following Typescript function:

  isAttendanceDuplicate(date: Date, attendances: Attendance[]): boolean {
    const dateValues = new Array<number>();
    attendances.filter(as => as.isHidden === false).forEach(a => {
      const attendanceDate = new Date(a.date.getFullYear(), a.date.getMonth(), a.date.getDate());
      dateValues.push(attendanceDate.valueOf())
    });
    const matchingDateVales = dateValues.filter(d => d === date.valueOf());

    return matchingDateVales.length > 0;
  }

And this is the definition for an attendance:

export class Attendance {
  calendarItemId: string;
  calendarItemTypeId: number;
  hasNoDueEvent: boolean;
  clientId: string;
  dueEventId: string;
  resultEventId: string;
  calendarItemName: string;
  type: number;
  status: number;
  date: Date;
  isHidden: boolean;
  statusName: string;
  hasOpenAlert: boolean;
}

As you can see in that class date is a Date.

When attempting to create a new Date (attendanceDate) I get the following error:

"TypeError: a.date.getFullYear is not a function." Why?

about 4 years ago · Juan Pablo Isaza
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!