https://github.com/alexcanessa/typescript-coverage-report
Node command tool to generate TypeScript coverage report
https://github.com/alexcanessa/typescript-coverage-report
coverage coverage-report ts type-coverage typescript typescript-coverage
Last synced: 29 days ago
JSON representation
Node command tool to generate TypeScript coverage report
- Host: GitHub
- URL: https://github.com/alexcanessa/typescript-coverage-report
- Owner: alexcanessa
- License: mit
- Created: 2020-03-15T15:16:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-28T08:21:46.000Z (2 months ago)
- Last Synced: 2025-04-13T13:54:54.040Z (29 days ago)
- Topics: coverage, coverage-report, ts, type-coverage, typescript, typescript-coverage
- Language: TypeScript
- Homepage:
- Size: 1.92 MB
- Stars: 504
- Watchers: 4
- Forks: 33
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TypeScript Coverage Report
[](https://badge.fury.io/js/typescript-coverage-report)
[](https://www.npmjs.com/package/typescript-coverage-report)
[](https://github.com/RichardLitt/standard-readme)
[](https://opensource.org/licenses/mit-license.php)
[](https://github-tools.github.io/github-release-notes/)[](#contributors-)
Node command line tool for generating TypeScript coverage reports ✨
## Overview
This package fills the gap of a missing type coverage reporting tool which is present in the Flow ecosystem, strongly inspired by the amazing work done by [`flow-coverage-report`](https://github.com/rpl/flow-coverage-report) and using data generated by [`type-coverage`](https://github.com/plantain-00/type-coverage).
[See an example of the coverage report](https://alexcanessa.github.io/typescript-coverage-report/).
### Background
To learn more about the reasoning behind this project and its roadmap, please refer to the following article: [**How I built a TS coverage report tool**](https://medium.com/@alexcanessa/how-did-i-build-a-ts-coverage-report-tool-af34e110d02c?sk=de2eb6c78e581aa8d9979629300873b3)
## Install
`typescript-coverage-report` can be installed locally or globally.
Users are advised to install it as a project _(dev)_ dependency and create a script in `package.json`.
```shell
$ yarn add --dev typescript-coverage-report# OR
$ npm install --save-dev typescript-coverage-report
```## Usage
If installed locally, add the following to the _scripts_ section of `package.json`.
```json
"scripts": {
"ts-coverage": "typescript-coverage-report"
}
```Then run:
```shell
$ yarn ts-coverage# OR
$ npm run ts-coverage
```To set the minimum threshold _(80% by default)_, use the `--threshold` option.
```shell
$ yarn ts-coverage --threshold=99
```As an alternative, options may be provided through the `type-coverage` [configuration](https://github.com/plantain-00/type-coverage#config-in-packagejson), specified in `package.json`.
```json
"typeCoverage": {
"atLeast": 90
}
```


## Options
The CLI accepts a list of arguments:
| Option | Description | Default value |
| ------------------------------- | -------------------------------------------------------------------------------------- | ------------- |
| `-t, --threshold [number]` | The minimum percentage of coverage required. | 80 |
| `-o, --outputDir [string]` | The output directory where to generate the report. | coverage-ts |
| `-s, --strict [boolean]` | Run the check in strict mode. | false |
| `-d, --debug [boolean]` | Show debug information. | false |
| `-c, --cache [boolean]` | Save and reuse type check result from cache. | false |
| `-p, --project [string]` | File path to tsconfig file, eg: --project "./app/tsconfig.app.json" | . |
| `-i, --ignore-files [boolean]` | Ignore specified files, eg: --ignore-files "demo1/\*.ts" --ignore-files "demo2/foo.ts" | false |
| `-u, --ignore-unread [boolean]` | Allow writes to variables with implicit any types | false |## Maintainers
[@alexcanessa](https://github.com/alexcanessa)
## Contributing
Feel free to dive in! [Open an issue](https://github.com/alexcanessa/typescript-coverage-report/issues/new/choose) or submit PRs.
On this project we follow the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/1/3/0/code-of-conduct/).
### Developing
Thanks for contributing!
Remember to run the following commands to link your version of this package and build the TypeScript files.
```bash
# Link the package globally, so you'll be able to test it in other projects.
$ yarn link
# Builds the TypeScript files and watches for changes
$ yarn build --watch
```### Commit messages
This project follows the [Angular commit messages](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit), but it's very open to emojis 🤯.
### Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
David Tsai
📖 🐛
Alexis Tyler
🐛
Dan Vanderkam
💻
Daniel Edholm Ignat
💻
Kyℓe Hensel
💻
Danilo Cabello
💻
Sanjay Guruprasad
🐛
Luis Helder
🐛
Tom Ardern
🐛 💻
lroskoshin
💻
Max Burmagin
💻
Alexander Skvortsov
💻
Adi Cucolaș
💻
Stanislav Golyshev
💻
roikoren755
💻
jinphic
💻
Brandon Barker
💻
Stanyslas Bres
💻
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## Licence
[MIT](https://spdx.org/licenses/MIT.html) @ Alessandro Canessa
[](https://forthebadge.com)