I would like to ignore some files when type checking some files using tsc and cannot figure out how this is done in TypeScript. Tools like eslint or flow allow special comments in the source files that allow to control the compiler.
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-ignore comment to disable type checking for a line in TypeScript. The comment disables type checking for the next line. If you use a linter, you might need to disable it for the line on which you use the // @ts-ignore comment. Copied!
Running tsc locally will compile the closest project defined by a tsconfig. json , you can compile a set of TypeScript files by passing in a glob of files you want.
The tsc command envokes the TypeScript compiler. When no command-line options are present, this command looks for the tsconfig. json file. If no tsconfig.
In individual files, you can ignore specific lines by adding // @ts-ignore
on the preceding line.
more about it here (// ts-ignore
does not work with .ts files however as of now)
and exclude files/folders using glob patterns in your tsconfig.json
as below as long long as they aren't imported in other files such as in the case of independent unit test files and the like
{
"exclude": [
"**/*.spec.ts"
]
}
more about that, here
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