An interactive Bash script to help audit the performance of your Typescript types.
|
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.
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
