Skip to content
/ tracer Public

A VSCode extension to measure type complexity within a project.

License

Notifications You must be signed in to change notification settings

tsperf/tracer

Repository files navigation

Type Complexity Tracer

Visual Studio Marketplace Version

A VSCode extension to measure type complexity within a project.

🚧 It is a work in progress - help is wanted! 🚧

Real-time type checking estimates

To avoid the overhead of launching a separate tsserver, it currently queries the VSCode language server to get information about tokens in an open file, and uses the timings of the responses as a proxy for the complexity of the types, following the pattern of @definitelytyped/perf.

Trace file view and metrics

The Tracer: tsc trace command can be run to gather accurate timings. As with real-time metrics, these create diagnostics in the editor open files. It also opens an interface to browse trace files. Editor and UI commands enable navigating between locations in the editor and the trace.

If the trace is run with a version of tsc that includes timestamps in types.json, type count metrics are also displayed. A PR to include these timestamps or tooling to automatically patch them in are works in progress. See https://github.com/typeholes/TypeScript/tree/trace-data-5-4 for a version you can build yourself.

Use in mono repos

Better support for mono repos is on the roadmap. For now you can run traces for packages via the context menu in the file tree

Credits

We are grateful to Algora for creating the TSPerf Type Challenge and to its sponsors.

Help wanted

  • Improve UX/API of the plugin - for example, more settings to customise how data is displayed to the user and better display of the traces
  • Investigate persistent worker threads that watch changes in a project and update asynchronously (and do not need to reinitialise TypeScript)
  • See if it is possible to get extended diagnostics or other diagnostic data from the compiler or tsserver APIs

License

Published under the MIT License.