narrow-any-scope
Use the Narrowest Possible Scope for any Types
Overview
If you must use any, contain the damage.
any is contagious - it spreads through your code. Keep it as narrowly scoped as possible to limit its impact on type safety.
When to Use This Skill
- Forced to use any for some reason
- Working with untyped third-party code
- Dealing with complex type errors
- Migrating JavaScript to TypeScript
- Reviewing code that uses any
The Iron Rule
More from marius-townhouse/effective-typescript-skills
precise-any-variants
Use when forced to use any. Use when any is too broad. Use when function types need any.
86tsdoc-comments
Use when documenting public APIs. Use when writing library code. Use when using JSDoc-style comments. Use when generating documentation. Use when explaining complex types.
34exhaustiveness-checking
Use when handling tagged unions. Use when adding new cases to discriminated unions. Use when switch statements must cover all cases.
13code-gen-independent
Use when confused about types at runtime. Use when trying to use instanceof with interfaces. Use when type errors don't prevent JavaScript output.
12tsconfig-options
Use when setting up a TypeScript project. Use when confused by type checking behavior. Use when strict mode causes unexpected errors.
11exclusive-or-properties
Use when exactly one of several properties should be present. Use when modeling mutually exclusive options. Use when building component props with alternative configurations. Use when designing API parameters that have variants.
11