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

551
Vistas
TYPEORM TypeError: Cannot read properties of undefined (reading 'length')

I managed to make a connection to an Azure Database but at the moment of creating the tables, the server fails with this error:

[path]/node_modules/typeorm/driver/sqlserver/SqlServerQueryRunner.js:2309
                        if (!dbTables.length)
                                      ^

TypeError: Cannot read properties of undefined (reading 'length')
    at SqlServerQueryRunner.<anonymous> ([path]/node_modules/typeorm/driver/sqlserver/SqlServerQueryRunner.js:2309:39)
    at step ([path/node_modules/tslib/tslib.js:143:27)
    at Object.next ([path]/node_modules/tslib/tslib.js:124:57)
    at fulfilled ([path]/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I tried to look for the solution but there isn't. I would be very thankful if you help me

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your dbTables variable is not defined. Compiler didn't catch this earlier because you used the non-null assertion operator (bang operator: !).

Instead of using this assertion you should adjust behaviour of your program, for example:

// check first if variable is defined
if (dbTables && dbTables.length) {}

Same but shorter:

if (dbTables?.length) {}

Your case is perfect example of why overusing non-null assertion operator can be dangerous for your code base. We should use it only when for some reason we have better knowledge of types than the compiler, which is rather rare.

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