{"data":{"slug":"github-thedaviddias-front-end-checklist-skills-no-explicit-any-13947a0d6642","title":"Avoid 'any' Type in TypeScript for Type Safety","summary":"Replace 'any' with 'unknown', generics, or Zod validation in TypeScript code to improve type safety and prevent type regression. This skill is ideal for code reviews, refactoring, and maintaining type-safe codebases.","url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-no-explicit-any-13947a0d6642","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-thedaviddias-front-end-checklist-skills-no-explicit-any-13947a0d6642","markdown_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-no-explicit-any-13947a0d6642.md","download_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-no-explicit-any-13947a0d6642\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before applying this skill, ensure that the TypeScript codebase is set up with ESLint and the @typescript-eslint\/no-explicit-any rule enabled. The first deliverable is a list of all 'any' type usages with suggested replacements, formatted as a report.","instructions":"---\nname: no-explicit-any\ndescription: \"Use when reviewing TypeScript files for type safety regressions, during code review of functions that handle external data, or when the codebase has ESLint warnings for @typescript-eslint\/no-explicit-any.\"\nmetadata:\n  category: javascript\n  priority: medium\n  difficulty: intermediate\n  estimatedTime: \"20\"\n  source: frontendchecklist.io\n  url: https:\/\/frontendchecklist.io\/rules\/javascript\/no-explicit-any\n---\n\n# Avoid the any type \u2014 use unknown, generics, or type guards instead\n\nThe any type is a local opt-out that becomes a global problem: a function returning any propagates unchecked types to every caller, silently undermining the type system across the entire codebase. Replacing any with unknown forces type narrowing at the point of use, turning latent runtime errors into compile-time failures where they are cheapest to fix.\n\n## Quick Reference\n\n- any disables all type checking for a value and cascades to callers\n- unknown is the safe alternative \u2014 it requires a type check before use\n- Use generics to express \"I accept any type, but it stays consistent\"\n- At API boundaries, validate with Zod rather than asserting with as Type\n\n## Check\n\nScan this TypeScript file for uses of the any type (explicit annotations, implicit any from missing types, and type assertions to any). Report each location and suggest a safer alternative.\n\n## Fix\n\nReplace the any types in this code with unknown (for values of unknown shape), appropriate generics (for type-consistent operations), or Zod validation (for external data). Show the narrowing or generic constraint needed at each usage site.\n\n## Explain\n\nExplain why the any type undermines TypeScript's guarantees, how unknown differs from any, and when a type assertion (as Type) is acceptable versus dangerous.\n\n## Code Review\n\nReview all type annotations, function signatures, and external data handling in this file. Flag every explicit or implicit any, any type assertion that lacks a preceding type guard, and any return types inferred as any from untyped dependencies.\n\n---\n\nFor full implementation details, code examples, and framework-specific guidance,\nsee `references\/rule.md`.\n\nRule page: https:\/\/frontendchecklist.io\/rules\/javascript\/no-explicit-any\n","use_cases":["Reviewing TypeScript files for type safety regressions","Refactoring code with ESLint warnings for @typescript-eslint\/no-explicit-any","Improving type safety in functions handling external data"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/thedaviddias\/Front-End-Checklist\/blob\/e8d14d049010e2ce25afcd5e8609dfcbbe63e47e\/skills\/no-explicit-any\/SKILL.md","source_commit":"e8d14d049010e2ce25afcd5e8609dfcbbe63e47e","license":null,"version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-22T17:11:07.000000Z","updated_at":"2026-11-24T07:12:05.000000Z","seo_title":"Avoid 'any' Type in TypeScript for Type Safety","seo_description":"Improve TypeScript type safety by replacing 'any' with 'unknown', generics, or Zod validation. Learn how to review and refactor code for better type guarantees.","seo_keywords":["TypeScript type safety","Avoid any type in TypeScript","Replace any with unknown","TypeScript code review","TypeScript refactoring"]}}