I have a large typescript file that I've inherited. The compiler has many complaints with this file, however it works just fine.
I'll come back to it, but is there any way to suppress all warnings/errors in a specific file?
Use // @ts-ignore to ignore the type checking errors on the next line in a TypeScript file. If you use a linter, you might have to add a comment to also suppress linting errors when using ts-ignore - // eslint-disable-next-line @typescript-eslint/ban-ts-comment . Copied!
Use the // @ts-nocheck comment to disable all type checking in a TypeScript file. If you need to disable all type checking for JavaScript files, set the checkJs option to false in your tsconfig. json file. When the option is disabled, errors are not reported in JS files.
A // @ts-ignore comment suppresses all errors that originate on the following line. It is recommended practice to have the remainder of the comment following @ts-ignore explain which error is being suppressed.
// @ts-ignore
comments
for lines// @ts-nocheck
after version 3.7 for the whole file.You can use // @ts-nocheck
at the top of the file
Files
Look how its done in the code above.
Check references.
https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/ https://github.com/microsoft/TypeScript/wiki/Type-Checking-JavaScript-
This is a little known trick. 2 steps:
/// <reference no-default-lib="true"/>
{
"compilerOptions": {
"skipDefaultLibCheck": true
}
}
Side note, as of 2019.4.11, skipDefaultLibCheck
option is marked as DEPRECATED in the doc, but the feature still exists in source code, see this line.
You could also use loose-ts-check to filter out and ignore some or all TypeScript errors in specific files.
It's used like this after initial setup:
tsc --noEmit | npx loose-ts-check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With