microsoft / microsoft/TypeScript

Provide type coverage metrics

Open
#36,802 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search Terms

  • type coverage
  • flow coverage

Suggestion

I'd love it if TypeScript had a tool to capture type coverage metrics, similar to Flow's Type Coverage feature. That coverage data could be used by IDEs (again, currently supported by Flow) to highlight gaps in type coverage. Basically, it should tell us which parts of our code are being evaluated as any.
Assuming it would work like Flow's feature, this could be a separate tsc option or separate cli command. Theirs works for single files and also offers a batch-coverage command for checking directories / whole projects, etc.

Use Cases

  • The Type Coverage metric could be used much like test coverage info, helping us to identify gaps in our typing (particularly unexpected gaps caused by insufficient type definitions from library code).

Examples

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Flow Type Coverage and batch-coverage documentation linked in the issue, then examine how TypeScript's tsc options or CLI commands could expose equivalent metrics. Done means reporting which parts of the code are evaluated as any for individual files and directory or project-wide coverage, with IDE-consumable data.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.