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

119
Vistas
What is really happening in this Typescript code. Having result is wrong with the hardcode string and parameterized string

I have a method to do some typeorm actions on an entity.

  async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
  code: barcode,
});

currentBarcode.isActive = true;

return await this.barcodeRepository.save(currentBarcode);

}

this prints an error message for the line "currentBarcode.isActive'

TypeError: Cannot set property 'isActive' of undefined

but when I hard code the barcode value in to the { code: 'hardcodebarcode'}, the line 'currentBarcode.isActive' has value and it works..

 async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
  code: '3sfsdfsderer',
});

currentBarcode.isActive = true;

return await this.barcodeRepository.save(currentBarcode);

}

My question, what is happening in this method which is causing this different behavior that 'when passed as parameter' or 'when hardcoded the same value'..

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