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

200
Vistas
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
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