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

93
Views
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 answers
Answer question

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