any-remover
v1.3.0
Published
Automatically remove unnecessary explicit 'any' types from TypeScript code
Downloads
404
Maintainers
Readme
any-remover
Automatically remove unnecessary explicit any types from TypeScript code.
Installation
npm install -g any-removerOr use directly with npx:
npx any-removerUsage
any-remover [options]Options
| Option | Description | Default |
|--------|-------------|---------|
| -p, --project <path> | Path to tsconfig.json | ./tsconfig.json |
| -d, --dry-run | Show what would be removed without making changes | false |
| --include <glob> | Only process files matching this glob | - |
| --exclude <glob> | Skip files matching this glob | - |
| -v, --verbose | Show detailed progress | false |
| --json | Output results as JSON | false |
| -y, --yes | Skip interactive prompts and process all files | false |
| --write-interval <ms> | Interval for periodic disk writes (ms) | 30000 |
Examples
Run on current project:
any-removerRun on a specific tsconfig:
any-remover -p ./packages/core/tsconfig.jsonPreview changes without modifying files:
any-remover --dry-runProcess only files in a specific directory:
any-remover --include "src/utils/**"Run non-interactively with JSON output:
any-remover -y --jsonHow It Works
any-remover uses a two-phase approach:
Phase 1 - Removal: Tests each
anytype annotation to see if it can be completely removed (letting TypeScript infer the type).Phase 2 - Replacement: For
anytypes that cannot be removed, tests if they can be safely replaced withunknown.
The tool uses smart batch processing with binary search to efficiently test changes while ensuring the project continues to compile.
Requirements
- Your project must compile successfully before running any-remover
- Node.js >= 18.0.0
- TypeScript >= 4.7.0
License
ISC
