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.