TypeScript Coverage Report

1.1.1 · active · verified Tue Apr 21

typescript-coverage-report is a Node.js command-line tool designed to generate comprehensive type coverage reports for TypeScript projects. It visually highlights areas in the codebase that lack strong typing, helping developers track progress in TypeScript adoption or maintain strict type discipline. Currently at version 1.1.1, the package seems to follow an ad-hoc release cadence, with previous minor versions addressing specific TypeScript compatibility issues and feature enhancements. Its key differentiator is being strongly inspired by and filling a similar niche to `flow-coverage-report` in the Flow ecosystem, leveraging data from the `type-coverage` package to analyze `any` usage.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install `typescript-coverage-report`, configure a `package.json` script, and run the CLI tool to generate an HTML type coverage report for a basic TypeScript project, setting a custom threshold and output directory.

{
  "name": "my-ts-project",
  "version": "1.0.0",
  "description": "A sample TypeScript project",
  "main": "dist/index.js",
  "scripts": {
    "build": "tsc",
    "ts-coverage": "typescript-coverage-report --threshold=95 --outputDir=./html-coverage"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "typescript": "^5.0.0",
    "typescript-coverage-report": "^1.1.1"
  }
}

// Create a tsconfig.json file in the root:
// {
//   "compilerOptions": {
//     "target": "ES2020",
//     "module": "CommonJS",
//     "strict": true,
//     "esModuleInterop": true,
//     "skipLibCheck": true,
//     "forceConsistentCasingInFileNames": true,
//     "outDir": "./dist"
//   },
//   "include": ["src/**/*.ts"]
// }

// Create a sample TypeScript file (e.g., src/index.ts):
// export function add(a: number, b: number): number {
//   return a + b;
// }

// export function subtract(a: any, b: number) {
//   // 'a' is implicitly 'any', reducing type coverage
//   return a - b;
// }

// Now run the coverage report:
// npm install
// npm run ts-coverage

view raw JSON →