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

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