typescript-strict-mode

Enforce strict TypeScript practices to eliminate unsafe any usage.

Updated Jan 23, 2024
One-click install
npx skills add https://github.com/TeamMagicOfConch/conch --skill typescript-strict-mode-teammagicofconch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-strict-mode
Source: https://github.com/TeamMagicOfConch/conch/tree/main/.agents/skills/typescript-strict-mode
Command: npx skills add https://github.com/TeamMagicOfConch/conch --skill typescript-strict-mode-teammagicofconch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps teams eliminate unsafe any usage and improve type safety by applying strict TypeScript rules across codebases.

Core Features & Use Cases

  • Enforces no-explicit-any via ESLint rules to catch unsafe types early.
  • Encourages using unknown for unknown data, generics for reusable components, and type guards for runtime validation.
  • Useful across code reviews, migrations to strict mode, and new feature development.

Quick Start

Apply strict TypeScript rules across your codebase by enabling the no-explicit-any rule, preferring unknown, and using generics and type guards.

Frequently Asked Questions about typescript-strict-mode

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

FAQPage Schema
How do I eliminate unsafe any usage in my TypeScript codebase?

To eliminate unsafe any usage in TypeScript, enable the no-explicit-any ESLint rule and adopt type-safe patterns. Replace any with unknown for dynamic data, apply generics for reusable components, and use type guards for runtime validation.

When should I use unknown instead of any in strict TypeScript mode?

Use unknown instead of any in strict TypeScript mode when handling truly unknown external data. The unknown type forces explicit runtime type checking via type guards before usage, ensuring type safety and preventing uncaught runtime errors.

How do I enforce strict TypeScript rules during code reviews and onboarding?

Enforce strict TypeScript rules during code reviews and onboarding by applying strict mode configurations project-wide. Guide developers to leverage Record types, generics, and type guards, rejecting unsafe patterns early to maintain a consistent and safer codebase.

What is the best way to migrate a TypeScript project to strict mode?

The best way to migrate a TypeScript project to strict mode is to incrementally apply strict type safety rules. Start by enabling no-explicit-any via ESLint, then refactor dynamic types to unknown and implement type guards to resolve compiler errors safely.

Does ESLint no-explicit-any work with generics and type guards?

Yes, the ESLint no-explicit-any rule works seamlessly with generics and type guards. These strict TypeScript patterns provide the type-safe alternatives needed to satisfy the linter, allowing you to model dynamic data safely without disabling the rule.

Why does strict TypeScript mode require type guards for unknown data?

Strict TypeScript mode requires type guards for unknown data because the unknown type prevents direct property access without validation. Type guards perform runtime checks that narrow the type, ensuring safe data handling and eliminating unsafe any casting.