no-explicit-any
できること
このスキルは、型チェックを無効にしてしまう「any」型の使用をTypeScriptファイルで確認します。TypeScriptでより多くのミスを早く見つけたい開発者向けです。
使う場面
- ✓TypeScriptファイルの型の安全性を確認するようエージェントに頼むとき。
- ✓リンターが「any」型について警告を出し、適切に直したいとき。
- ✓アプリの外部から来たデータを扱う関数で、使う前に検証したいとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/no-explicit-any/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のTypeScriptファイルを確認し、「any」型をより安全な型に置き換えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、暗黙的な場合や型アサーションを含め、「any」が使われているすべての箇所を見つけます。unknown、ジェネリクス、検証などの置き換えを提案し、各値を使う場所で必要なチェックを示します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Avoid the any type — use unknown, generics, or type guards instead
The 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.
Quick Reference
- any disables all type checking for a value and cascades to callers
- unknown is the safe alternative — it requires a type check before use
- Use generics to express "I accept any type, but it stays consistent"
- At API boundaries, validate with Zod rather than asserting with as Type
Check
Scan 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.
Fix
Replace 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.
Explain
Explain why the any type undermines TypeScript's guarantees, how unknown differs from any, and when a type assertion (as Type) is acceptable versus dangerous.
Code Review
Review 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.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/no-explicit-any
よくある質問
「any」と「unknown」の違いは何ですか?
「any」は型チェックを完全に無効にするのに対し、「unknown」は値を使う前に型の確認を必要とします。
型アサーションを使うのは問題ありませんか?
このスキルによると、場合によっては受け入れられますが、実際の問題を隠すために使うと危険です。
外部データを境界で検証するのはなぜですか?
このスキルは、型アサーションをせず、Zodなどの検証ライブラリで外部データを確認することを勧めています。
詳細
作者による元の説明
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.
人気
- GitHubのスター
- 75k
- ランキング
- #2950
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。