iterate-objects-safely
✓オブジェクトのキーと値を反復処理するときに使用します。 for...in ループで型エラーが発生する場合に使用します。 Object.entries が任意の型を返す場合に使用します。プロトタイプの汚染に関する懸念に対処する場合に使用します。マップとオブジェクトを検討する場合に使用します。
SKILL.md
Iterating over objects in TypeScript is surprisingly tricky. The for...in loop infers keys as string rather than the object's keys, leading to indexing errors. This happens because objects can have additional properties beyond their declared type (structural typing), and for...in includes inherited properties.
Understanding safe iteration patterns helps you avoid any types and type assertions while correctly handling object traversal.
Use Object.entries for safe iteration over any object. Use for...in with keyof assertions only when you know the exact shape. Consider Map for guaranteed type safety.
オブジェクトのキーと値を反復処理するときに使用します。 for...in ループで型エラーが発生する場合に使用します。 Object.entries が任意の型を返す場合に使用します。プロトタイプの汚染に関する懸念に対処する場合に使用します。マップとオブジェクトを検討する場合に使用します。 ソース: marius-townhouse/effective-typescript-skills。
引用可能な情報
AI/検索での引用用の安定したフィールドとコマンド。
- インストールコマンド
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill iterate-objects-safely- カテゴリ
- </>開発ツール
- 認証済み
- ✓
- 初回登録
- 2026-02-05
- 更新日
- 2026-02-18
クイックアンサー
iterate-objects-safely とは?
オブジェクトのキーと値を反復処理するときに使用します。 for...in ループで型エラーが発生する場合に使用します。 Object.entries が任意の型を返す場合に使用します。プロトタイプの汚染に関する懸念に対処する場合に使用します。マップとオブジェクトを検討する場合に使用します。 ソース: marius-townhouse/effective-typescript-skills。
iterate-objects-safely のインストール方法は?
ターミナルまたはコマンドラインツール(Terminal、iTerm、Windows Terminal など)を開きます このコマンドをコピーして実行します: npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill iterate-objects-safely インストール後、スキルは自動的に AI コーディング環境に設定され、Claude Code や Cursor で使用できるようになります
ソースリポジトリはどこですか?
https://github.com/marius-townhouse/effective-typescript-skills
詳細
- カテゴリ
- </>開発ツール
- ソース
- skills.sh
- 初回登録
- 2026-02-05