Skip to content

Latest commit

History

History
67 lines (49 loc) 路 1.6 KB

Usage.md

File metadata and controls

67 lines (49 loc) 路 1.6 KB

Usage

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.

Basic Usage

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
	}
}

Multi-Step Configurations

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:

  1. Add the above noImplicitAny fixes
  2. Trim out any unnecessary types that TypeScript can infer from usage
[
	{
		"fixes": {
			"noImplicitAny": true
		}
	},
	{
		"fixes": {
			"noInferableTypes": true
		}
	}
]

Verbose Logging

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

More Examples

Use these examples as more granular references of how to perform targeted changes with TypeStat.