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

211
Views
How to export two modules/namespaces with same name from multiple files in typescript in index.d.ts?

I'm building a new npm package, I have two different typescript files, they contain namespaces and modules with same name 'X' at the end of each file i declare :

export default X;

I want to import them both into index.d.ts file and export them so the outer files (the files that import this repository/package) can import and use X modules and namespaces

But when I import them both:

import X from "./file1"
import X from "./file2"

I get this error:

Duplicate identifier 'X'

Is there a way to have the same namespace in two different typescript file and export them to outer packages?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, there is - using aliases.

file1.ts

class A{}
export default A;

file2.ts

class A{}
export default A;

index.ts

import { default as firstOne } from './file1';
import { default as secondOne } from './file2';
console.log(firstOne, secondOne);
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!