Skip to content

Pixelmatters/ts-check-filter

Repository files navigation

TS Check Filter

A filter for TypeScript errors.

This is useful when using code-generation tools or while migrating to a strict tsconfig.json, allowing a smother and incremental transition.

ts-check-filter license. Current npm package version. PRs welcome! Follow @pixelmatters_

Features

  • Ignore files based on relative path or regular expression
  • Ignore specific TS errors

Why can not be excluded on TypeScript?

The exclude option in tsconfig.json makes tsc not directly check the file. Unfortunately, if the file is used from another checked file, it will report an error. This way, it will not solve some use cases.

Usage

To install:

npm i @pixelmatters/ts-check-filter

To use the filter pipe the results into ts-check-filter:

tsc --noEmit | npx ts-check-filter

To define the paths to be ignored create a new ts-check-filter.js file on the project root:

module.exports = {
  pathFilterRules: [/src\/__generated__\/.*/],
}

The pathFilterRules is an array of strings or RegExp. In the example above, we use a regular expression to ignore all the files under the __generated__ directory.

Note: If you don't pep anything into the filter it will be waiting for ever for an input.

Options

Display the list of options by executing:

npx ts-check-filter --help

Development

For the development is recommended to use PNPM, since is the tool that is being used to manage dependencies. So to install just run:

pnpm install

To test implementation and check if the code follows the right guidelines, please run:

pnpm test

🤝 How to Contribute

Whether you're helping us fix bugs, improve the docs, or spread the word, thank you! 💪 🧡

Check out our Contributing Guide for ideas on contributing and setup steps.

📝 License

Licensed under the BSD-2 License.