Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!