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

181
Vistas
Importing javascript function into Typescript file: function is seen as namespace

I'm trying to import a plain javascript function into a typescript file. I'm working on a React Native app.

The import is working when its just JS, but on TS I get the error: Cannot use namespace 'PrimaryButton' as a type

The javascript function resides in a node module which exports its function as such in its index.js:

export {default as PrimaryButton} from './src/components/PrimaryButton.js';

The node module is called component-library, it is a company own node module. It does not contain any types at all, only plain JS.

I have included a custom.d.ts file in the RN app where I declare component-library as a module to avoid TS errors on import:

declare module 'component-library';

Now, when trying to import the PrimaryButton function, I get the error Cannot use namespace 'PrimaryButton' as a type.

What is the easiest way to enable to import of the PrimaryButton function without errors? I'm pretty new to Typescript and kind of lost here.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ended up being something really simple... The file had the .ts extension instead of .tsx, so when using the tsx syntax it was detected as a type instead because of the <Component> notation.

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