package
Kill every redundant type assertion in your TypeScript codebase
npm install asserticideGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.

Kill every redundant type assertion and non-null assertion in your TypeScript codebase
For each assertion.
tsgo.What survives is the set of assertions actually doing work — plus the small set preserved by rule.
A few cases where an assertion is kept even though tsgo would accept the deletion:
as const — never touched.as never — never touched; almost always an intentional type hack.x as T when removing it would let any from x silently propagate (and T ≠ any).x as any as T — neither half is removed in a way that would change the value's effective type.{ ... } as T initializing an unannotated variable — the assertion drives the object literal's contextual typing.x! when strictNullChecks is off — usually scaffolding for an in-progress migration to strict null checks.npx asserticide # uses ./tsconfig.json
npx asserticide path/to/tsconfig.json
npx asserticide path/to/dir # uses path/to/dir/tsconfig.jsonRequires Node ≥ 24. asserticide refuses to run if the project doesn't typecheck cleanly under tsgo. Commit your working tree first so you can review the diff afterwards.
Sample output:
---
total assertions found: 412
removed assertions: 287
reverted by typecheck: 118
preserved by rule: 7
files changed: 54
- src/api/client.ts
- src/components/Grid.tsx
- ...no-unnecessary-type-assertionThe difference is scale.
The @typescript-eslint/no-unnecessary-type-assertion lint rule works at the expression level: it reports an assertion when removing it preserves the expression type or still satisfies the contextual type at that position.
asserticide works at project level: it tries deleting each type assertion, runs tsgo, and keeps the edit if the checked project still typechecks and no preservation rule applies.
So asserticide can remove assertions with real local type effects when those effects are unused projectwide.
Estimated unpacked size across 30 packages.
720.5 MB
Includes dependencies.