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

100
Visualizações
classes_1.Person is not a constructor

I am using a TypeScript project I made by myself, but I am having some issues with imports and exports.

I have a folder classes with each class having it's specific file that exports the class. I then have a file index.ts, which imports all the classes and exports them from one file for easier use in code.

Person.ts:

class Person {}

export default Person

index.ts:

import Person from "./Person"

export { Person }

app.ts:

import { Person } from "@classes

const person = new Person()

The issue is that the above code does not work and fires an error classes_1.Person is not a constructor

I am using alias paths configured in tsconfig.json as so:

"paths": {
    "@classes": ["classes"],
    "@interfaces": ["interfaces"],
    "@enums": ["enums"],
    "@const": ["const"]
}

I am not using the format that is shown in TS docs: "@classes/*": ["classes/*"] as that is not ideal for my use case.

I compile the code with npx tsc && npx tsc-alias

If I look into the transpiled .js code, the VSCode understands all imports, but if I launch the app with node ./dist/app.js, it does not work.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had a circular dependency between the files. In index.ts I was importing multiple classes, which were dependent on each other in some way. I fixed it by moving the depending class to the top, so the import statement imports that class first.

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