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

235
Visualizações
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 à 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