You'll need to tailor TypeStat's settings for your project.
It is strongly recommended to start with the typestat
CLI tool to auto-generate a configuration file for you.
npx typestat
This will launch an interactive guide to setting up a typestat.json
configuration file.
That file instructs subsequent runs to apply a series of "fixes" to your code.
npx typestat --config typestat.json
For example, the following typestat.json
will add auto-fixes for missing type annotations to solve TypeScript's noImplicitAny
complaints:
{
"fixes": {
"noImplicitAny": true
}
}
typestat.json
can contain either a single object describing fixes to make or an array of those objects describing fixes to run in order.
For example, the following typestat.json
will:
- Add the above
noImplicitAny
fixes - Trim out any unnecessary types that TypeScript can infer from usage
[
{
"fixes": {
"noImplicitAny": true
}
},
{
"fixes": {
"noInferableTypes": true
}
}
]
Curious about how fixes are being suggested?
Run with a --logfile
to get a detailed, verbose log of the exact fixes applied to each file.
npx typestat --logfile typestat.log
Use these examples as more granular references of how to perform targeted changes with TypeStat.