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

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

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