Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda