Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

550
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda