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

115
Views
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
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!