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

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