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

113
Visualizações
Typecheck a TypeScript typed function call in a JavaScript file

I'm progressively migrating a JavaScript React app (CRA) to TypeScript. After having ran npm i typescript @types/node @types/react @types/react-dom @types/jest and npx tsc --init, I assigned types to a utility function, says

export const toNumber = (s : string) : number => +s;

and changed the extension of the file containing it from .js to .ts.

Now, if I write

const n = toNumber(5); 

in the very same .ts file, a typing error does show up on both react-scripts start and VSCode as expected. But if I import toNumber in a .js file and write the same expression, there is no error whatsoever.

Is it possible to enable typechecking of an imported TypeScript function in a .js file (while ignoring everything not typed)?

about 4 years ago · Juan Pablo Isaza
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