Skip to content
geoffreytoolsPublic

About

An interactive Bash script to help audit the performance of your Typescript types

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

ts-trace

An interactive Bash script to help audit the performance of your Typescript types.

Features

  • Trace a specific path or list of paths;
  • Replay a specific trace;
  • Create snapshots;
  • Batch process multiple traces;
  • Trace once and exit, for scripts.

What it does

  1. Extend a base tsconfig.json and override the include field with the list of paths you supply;

  2. Run tsc --generateTrace with that new config as the --project;

  3. Record your input in a persistent log sorted by recency.

preview

Motivation

tsc --generateTrace is slow and the output is not very easy to interpret.

If you want to find your cubs and iterate quickly, you need to trace specific parts of your project.

Manually editing a tsconfig.json each time you want to trace something (or creating as many as you need) and comparing traces is a chore and is a bit messy.

How to use

If you are on Windows I imagine you have Git Bash installed (don't ask me why I did not do it in node...)

"install" it with npm (or simply drop ts-trace.sh somewhere in your project):

npm install github:geoffreytools/ts-trace

Run it with npx ts-trace, or add it to your npm-scripts in package.json:

"scripts": {
    "trace": "ts-trace"
}

By default, the script is looking for a base tsconfig.json file in the root of your project where it also creates a ts-trace directory in which your traces/ and the log will be located .

You can override the location of:

  • the base tsconfig with the option -i
  • the output folder with the option -o

For example

"scripts": {
    "trace": "ts-trace -i ./src/tsconfig.json -o ./profiling"
}

The option -c traces once and exits, which suits scripts and tools that cannot answer a prompt. The arguments after the options are the paths to trace, as one trace. They are recorded in the log, as in the interactive mode, and the exit status is the one of tsc:

npx ts-trace -c src/models src/store.ts

About

An interactive Bash script to help audit the performance of your Typescript types

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages