ban-type-assertions

Enforce the consistent-type-assertions ESLint rule to ban unsafe type assertions in TypeScript.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/ElbertePlinio/dotfiles --skill ban-type-assertions-elberteplinio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ban-type-assertions
Source: https://github.com/ElbertePlinio/dotfiles/tree/main/private_dot_factory/plugins/marketplaces/factory-plugins/plugins/typescript/skills/ban-type-assertions
Command: npx skills add https://github.com/ElbertePlinio/dotfiles --skill ban-type-assertions-elberteplinio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the risk of runtime errors caused by unsafe type assertions in TypeScript that bypass compiler checks, ensuring all type conversions are verified by the compiler or runtime validation.

Core Features & Use Cases

  • Lint Rule Enforcement: Enables the consistent-type-assertions ESLint rule to ban as type casts across a package.
  • Tiered Replacement Workflow: Provides a prioritized set of patterns to replace unsafe assertions, including Zod parsing for external data, control flow narrowing for union types, and justified eslint disables for unavoidable edge cases.
  • Shared Schema Consolidation: Guides promotion of duplicate types and schemas to a shared common library to reduce duplication and improve maintainability.
  • Use Case: For a TypeScript monorepo with multiple packages, use this Skill to eliminate all unsafe type casts, reduce runtime type errors, and centralize shared type definitions in a common package.

Quick Start

Use the ban-type-assertions skill to enable the consistent-type-assertions lint rule and replace all as type casts with compiler-verified alternatives in your TypeScript package.

Frequently Asked Questions about ban-type-assertions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I ban unsafe type assertions in a TypeScript monorepo?

To ban unsafe type assertions in a TypeScript monorepo, enable the @typescript-eslint/consistent-type-assertions rule with assertionStyle set to never. This eliminates unsafe as type casts by enforcing compiler-verified type conversions across all packages.

What is the best way to replace TypeScript as type casts with runtime validation?

The best way to replace TypeScript as type casts is using a tiered workflow: apply Zod parsing for external data, use control flow narrowing for union types, and add justified eslint disables for unavoidable edge cases to ensure runtime validation.

How does enforcing consistent type assertions improve type safety?

Enforcing consistent type assertions improves type safety by preventing type casts that bypass compiler checks. This eliminates runtime errors by ensuring all type conversions are verified by the compiler or validated via schema parsing libraries.

Can I consolidate duplicate TypeScript schemas across multiple packages?

Yes, you can consolidate duplicate TypeScript schemas across multiple packages by promoting them to a shared common library. This reduces duplication, improves maintainability, and centralizes type management across distributed packages.

When should I use eslint disables for unavoidable type assertions?

You should use eslint disables for unavoidable type assertions when replacing unsafe casts is not possible through Zod parsing or control flow narrowing. This handles edge cases while still enforcing the consistent-type-assertions rule across the codebase.

Does banning type assertions work with Zod for external data parsing?

Banning type assertions works seamlessly with Zod for external data parsing by replacing unsafe casts with schema parsing. This ensures runtime validation of external data, satisfying requirements for compiler-verified type safety without manual type assertions.