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

101
Vistas
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 Respuestas
Responde la pregunta

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 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