Skip to content

Instantly share code, notes, and snippets.

@erhangundogan
Last active January 11, 2024 20:58
Show Gist options
  • Save erhangundogan/bef6e83f6324cb76523bd8d3169c3de5 to your computer and use it in GitHub Desktop.
Save erhangundogan/bef6e83f6324cb76523bd8d3169c3de5 to your computer and use it in GitHub Desktop.
TypeScript compiler CLI commands to debug and diagnose your builds
# npm i -g typescript
# change directory to your project
# Prints out tsconfig.json including extended options if there is any.
tsc --showConfig
# You can use this flag to discover where TypeScript is spending it’s time when compiling
# https://github.com/microsoft/TypeScript/wiki/Performance
tsc --extendedDiagnostics
# Print names of files part of the compilation. This is useful when you are not sure that TypeScript has included a file you expected.
# Prefer --explainFiles if you have TypeScript version 4.2 or higher.
tsc --listFiles
# Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
# v4.2 or higher
tsc --explainFiles
# This option gives you the chance to have TypeScript emit a v8 CPU profile during the compiler run. The CPU profile can provide insight into why your builds may be slow.
# https://developer.chrome.com/docs/devtools/evaluate-performance/
# https://github.com/microsoft/TypeScript/wiki/Performance
# v3.7 or higher
tsc --generateCpuProfile tsc-cpu-profile.json
# When you are trying to debug why a module isn’t being included. You can set traceResolutions to true to have TypeScript print information about its resolution process for each processed file.
# v2.0 or higher
tsc --traceResolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment