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

234
Views
How do I ignore a Typescript error in a Javascript file (whilst I have `allowJs` set in my tsConfig)?

I have a handful of .js files in my Typescript project that looks something like this:

// do some things

return JSON.stringify(
  {
    ok: true,
    // blah blah blah
  },
  null,
  2
);

However, when I run tsc to type check my project, which has allowJs enabled, I receive this error:

error TS1108: A 'return' statement can only be used within a function body.
  return JSON.stringify(
  ~~~~~~

I'm confident in why I'm doing this (the code gets handed over to Snowflake) and would like to ignore this error.

Normally I would include a // @ts-expect-error directly above the offending return statement, however, this doesn't work. Apparently, because it's a javascript file, not a typescript file: if I change the file extension to .ts, the // @ts-expect-error comment behaves as expected and suppresses the error, however, it causes a bunch of other errors, as should be expected.

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!