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

187
Vistas
Issue after upgrading Angular 12 to Angular 13: a deepClone function works in version 12, but do not assign functions in version 13

I've recently updated angular version from 12 to 13. I have a class with a clone method. The implementation of the the class is something like this:

export class MyClass {

...

public clone(): MyClass {
   const newObject: MyClass = Util.deepClone(this);

   newObject.updateProperty();

   return newObject;
}

...

}

The deepClone method at Util class has the following implementation:

/**
   * Returns a deep copy of the object
   */
  public static deepClone(oldObj: any) {
    let newObj = oldObj;
    if (oldObj && typeof oldObj === 'object') {
      if (oldObj instanceof Date) {
        return new Date(oldObj.getTime());
      }
      newObj =
        Object.prototype.toString.call(oldObj) === '[object Array]' ? [] : {};
      for (const i in oldObj) {
        newObj[i] = this.deepClone(oldObj[i]);
      }
    }
    return newObj;
  }

My problem is: this piece of code works in version 12, but it doesn't in version 13. The function updateProperty() is undefined in version 13, but it is ok in version 12.

As I couldn't find anyone with similar issues neither similar questions, I would like some help to find:

  1. what changed from Angular 12 to Angular 13 that makes this piece of code stop working in version 13?
  2. how to solve the issue?
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