frontend-types
All TypeScript types are defined in `frontend/types/index.ts`. Types match backend API response structure and provide type safety across the frontend application.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o frontend-types.zip https://jpskill.com/download/17304.zip && unzip -o frontend-types.zip && rm frontend-types.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17304.zip -OutFile "$d\frontend-types.zip"; Expand-Archive "$d\frontend-types.zip" -DestinationPath $d -Force; ri "$d\frontend-types.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
frontend-types.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
frontend-typesフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Frontend TypeScript Types Skill
目的: frontend/types/index.ts の既存のパターンに従った TypeScript 型定義を作成するためのガイダンスです。
概要
すべての TypeScript 型は frontend/types/index.ts で定義されています。型はバックエンド API のレスポンス構造と一致し、フロントエンドアプリケーション全体で型安全性を実現します。
frontend/types/index.ts からの型パターン
1. User 型
export interface User {
id: string;
email: string;
name: string;
createdAt?: string;
updatedAt?: string;
}
export interface UserCredentials {
email: string;
password: string;
}
export interface UserSignupData extends UserCredentials {
name: string;
}
パターン:
- オブジェクト型には
interfaceを使用します - オプションのフィールドは
?でマークします - 型の継承には
extendsを使用します - フロントエンドの型には camelCase を使用します (バックエンドが snake_case を使用している場合でも)
2. Task 型
export type TaskStatus = "pending" | "completed";
export type TaskPriority = "low" | "medium" | "high";
export interface Task {
id: number;
user_id: string;
title: string;
description?: string;
completed: boolean;
priority: TaskPriority;
due_date?: string;
tags: string[];
created_at: string;
updated_at: string;
}
export interface TaskFormData {
title: string;
description?: string;
priority?: TaskPriority;
due_date?: string;
tags?: string[];
}
export interface TaskQueryParams {
status?: "all" | "pending" | "completed";
sort?: "created" | "title" | "updated" | "priority" | "due_date";
search?: string;
page?: number;
limit?: number;
}
パターン:
- Union 型 (文字列リテラル) には
typeを使用します - オブジェクト型には
interfaceを使用します - バックエンドのフィールド名と一致させます (API フィールドの
user_id、due_date、created_atなどは snake_case) - フォームデータ用に個別の型を作成します (必須フィールドを除き、すべてオプション)
- クエリパラメータ用に個別の型を作成します (すべてオプション)
3. API レスポンス型
export interface ApiResponse<T = unknown> {
data?: T;
success: boolean;
message?: string;
error?: {
code: string;
message: string;
details?: unknown;
};
}
export interface PaginatedResponse<T> {
data: T[];
meta: {
total: number;
page: number;
limit: number;
totalPages: number;
};
}
パターン:
- 再利用可能な構造にはジェネリック型
<T>を使用します - デフォルトの型パラメータを提供します (
<T = unknown>) successの boolean フラグを含めます- オプションの
data、message、およびerrorフィールドを含めます metaオブジェクトを持つページネーションされたレスポンス用に個別の型を作成します
4. 認証型
export interface AuthResponse {
success: boolean;
token: string;
user: User;
}
export interface Session {
user: User;
token: string;
expiresAt: number;
}
パターン:
successの boolean を含めますtoken文字列を含めますuserオブジェクト (User 型) を含めます- セッションの
expiresAtタイムスタンプを含めます
5. エラー型
export interface AppError {
message: string;
code?: string;
statusCode?: number;
field?: string;
}
export interface FormErrors {
[key: string]: string | undefined;
}
パターン:
- エラーオブジェクトには
interfaceを使用します - オプションのフィールドは
?でマークします - 動的なオブジェクト型にはインデックスシグネチャ
[key: string]を使用します (FormErrors)
6. UI 型
export type LoadingState = "idle" | "loading" | "success" | "error";
export type ToastType = "success" | "error" | "warning" | "info";
export interface ToastMessage {
id: string;
type: ToastType;
message: string;
duration?: number;
}
パターン:
- Union 型 (文字列リテラル) には
typeを使用します - オブジェクト型には
interfaceを使用します - 一意の識別には
idを含めます - オプションのフィールドは
?でマークします
7. エクスポート/インポート型
export type ExportFormat = "csv" | "json";
export interface ImportResult {
imported: number;
errors: number;
errorDetails?: string[];
}
パターン:
- Union 型 (文字列リテラル) には
typeを使用します - 結果オブジェクトには
interfaceを使用します - 成功/エラー追跡のためのカウントを含めます
- オプションのエラー詳細配列を含めます
型の命名規則
インターフェース
- PascalCase:
User,Task,ApiResponse - 説明的な名前:
TaskFormData,UserSignupData
型 (Union 型)
- PascalCase:
TaskStatus,TaskPriority,LoadingState - 説明的な名前:
ToastType,ExportFormat
Props 型
- ComponentName + Props:
TaskItemProps,ProtectedRouteProps - 例:
interface TaskItemProps { task: Task; }
フォームデータ型
- EntityName + FormData:
TaskFormData,UserSignupData - 例:
interface TaskFormData { title: string; description?: string; }
クエリパラメータ型
- EntityName + QueryParams:
TaskQueryParams - 例:
interface TaskQueryParams { status?: "all" | "pending" | "completed"; }
バックエンドスキーマとの一致
フィールド名マッピング
バックエンド (snake_case) → フロントエンド (フォームデータの場合は camelCase、API レスポンスの場合は snake_case)
// バックエンド API レスポンス (バックエンドと完全に一致)
export interface Task {
id: number;
user_id: string; // バックエンドからの snake_case
title: string;
due_date?: string; // バックエンドからの snake_case
created_at: string; // バックエンドからの snake_case
updated_at: string; // バックエンドからの snake_case
}
// フロントエンド フォームデータ (使いやすくするために camelCase)
export interface TaskFormData {
title: string;
dueDate?: string; // フロントエンドのための camelCase
tags?: string[];
}
パターン:
- API レスポンス型はバックエンドと完全に一致します (snake_case)
- フォームデータ型は、フロントエンドでの使いやすさのために camelCase を使用します
- API との送受信時にフォーマットを変換します
必須フィールドとオプションフィールド
// バックエンド API レスポンス (バックエンドからのすべてのフィールド)
export interface Task {
id: number; // 必須 (バックエンドから)
user_id: string; // 必須 (バックエンドから)
title: string; // 必須
(原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Frontend TypeScript Types Skill
Purpose: Guidance for creating TypeScript type definitions following existing patterns from frontend/types/index.ts.
Overview
All TypeScript types are defined in frontend/types/index.ts. Types match backend API response structure and provide type safety across the frontend application.
Type Patterns from frontend/types/index.ts
1. User Types
export interface User {
id: string;
email: string;
name: string;
createdAt?: string;
updatedAt?: string;
}
export interface UserCredentials {
email: string;
password: string;
}
export interface UserSignupData extends UserCredentials {
name: string;
}
Pattern:
- Use
interfacefor object types - Mark optional fields with
? - Use
extendsfor type inheritance - Use camelCase for frontend types (even if backend uses snake_case)
2. Task Types
export type TaskStatus = "pending" | "completed";
export type TaskPriority = "low" | "medium" | "high";
export interface Task {
id: number;
user_id: string;
title: string;
description?: string;
completed: boolean;
priority: TaskPriority;
due_date?: string;
tags: string[];
created_at: string;
updated_at: string;
}
export interface TaskFormData {
title: string;
description?: string;
priority?: TaskPriority;
due_date?: string;
tags?: string[];
}
export interface TaskQueryParams {
status?: "all" | "pending" | "completed";
sort?: "created" | "title" | "updated" | "priority" | "due_date";
search?: string;
page?: number;
limit?: number;
}
Pattern:
- Use
typefor union types (string literals) - Use
interfacefor object types - Match backend field names (snake_case for API fields like
user_id,due_date,created_at) - Create separate types for form data (all optional except required fields)
- Create separate types for query parameters (all optional)
3. API Response Types
export interface ApiResponse<T = unknown> {
data?: T;
success: boolean;
message?: string;
error?: {
code: string;
message: string;
details?: unknown;
};
}
export interface PaginatedResponse<T> {
data: T[];
meta: {
total: number;
page: number;
limit: number;
totalPages: number;
};
}
Pattern:
- Use generic types
<T>for reusable structures - Provide default type parameter (
<T = unknown>) - Include
successboolean flag - Include optional
data,message, anderrorfields - Create separate type for paginated responses with
metaobject
4. Authentication Types
export interface AuthResponse {
success: boolean;
token: string;
user: User;
}
export interface Session {
user: User;
token: string;
expiresAt: number;
}
Pattern:
- Include
successboolean - Include
tokenstring - Include
userobject (User type) - Include
expiresAttimestamp for session
5. Error Types
export interface AppError {
message: string;
code?: string;
statusCode?: number;
field?: string;
}
export interface FormErrors {
[key: string]: string | undefined;
}
Pattern:
- Use
interfacefor error objects - Mark optional fields with
? - Use index signature
[key: string]for dynamic object types (FormErrors)
6. UI Types
export type LoadingState = "idle" | "loading" | "success" | "error";
export type ToastType = "success" | "error" | "warning" | "info";
export interface ToastMessage {
id: string;
type: ToastType;
message: string;
duration?: number;
}
Pattern:
- Use
typefor union types (string literals) - Use
interfacefor object types - Include
idfor unique identification - Mark optional fields with
?
7. Export/Import Types
export type ExportFormat = "csv" | "json";
export interface ImportResult {
imported: number;
errors: number;
errorDetails?: string[];
}
Pattern:
- Use
typefor union types (string literals) - Use
interfacefor result objects - Include counts for success/error tracking
- Include optional error details array
Type Naming Conventions
Interfaces
- PascalCase:
User,Task,ApiResponse - Descriptive names:
TaskFormData,UserSignupData
Types (Union Types)
- PascalCase:
TaskStatus,TaskPriority,LoadingState - Descriptive names:
ToastType,ExportFormat
Props Types
- ComponentName + Props:
TaskItemProps,ProtectedRouteProps - Example:
interface TaskItemProps { task: Task; }
Form Data Types
- EntityName + FormData:
TaskFormData,UserSignupData - Example:
interface TaskFormData { title: string; description?: string; }
Query Parameter Types
- EntityName + QueryParams:
TaskQueryParams - Example:
interface TaskQueryParams { status?: "all" | "pending" | "completed"; }
Matching Backend Schema
Field Name Mapping
Backend (snake_case) → Frontend (camelCase for form data, snake_case for API response)
// Backend API response (matches backend exactly)
export interface Task {
id: number;
user_id: string; // snake_case from backend
title: string;
due_date?: string; // snake_case from backend
created_at: string; // snake_case from backend
updated_at: string; // snake_case from backend
}
// Frontend form data (camelCase for easier use)
export interface TaskFormData {
title: string;
dueDate?: string; // camelCase for frontend
tags?: string[];
}
Pattern:
- API response types match backend exactly (snake_case)
- Form data types use camelCase for easier frontend usage
- Convert between formats when sending/receiving from API
Required vs Optional Fields
// Backend API response (all fields from backend)
export interface Task {
id: number; // Required (from backend)
user_id: string; // Required (from backend)
title: string; // Required (from backend)
description?: string; // Optional (from backend)
completed: boolean; // Required (from backend)
priority: TaskPriority; // Required (from backend)
due_date?: string; // Optional (from backend)
tags: string[]; // Required (from backend, can be empty array)
created_at: string; // Required (from backend)
updated_at: string; // Required (from backend)
}
// Frontend form data (only fields user can edit)
export interface TaskFormData {
title: string; // Required (user must provide)
description?: string; // Optional
priority?: TaskPriority; // Optional (has default)
due_date?: string; // Optional
tags?: string[]; // Optional (can be empty array)
}
Pattern:
- API response types include all fields from backend
- Form data types only include fields user can edit
- Mark optional fields with
? - Required fields don't have
?
Type Structure Patterns
1. Use interface for Objects
export interface User {
id: string;
email: string;
}
When to use: Object types with properties
2. Use type for Unions, Intersections, or Aliases
export type TaskStatus = "pending" | "completed";
export type TaskPriority = "low" | "medium" | "high";
When to use: Union types, intersections, or type aliases
3. Use Generic Types for Reusable Structures
export interface ApiResponse<T = unknown> {
data?: T;
success: boolean;
}
When to use: Reusable structures that work with different types
4. Mark Optional Properties with ?
export interface Task {
title: string; // Required
description?: string; // Optional
}
When to use: Fields that may not exist
Complete Example: Adding New Types
Step 1: Define Entity Type (matches backend)
export interface Category {
id: number;
user_id: string;
name: string;
color?: string;
created_at: string;
updated_at: string;
}
Step 2: Define Form Data Type (for user input)
export interface CategoryFormData {
name: string;
color?: string;
}
Step 3: Define Query Parameters Type (for API queries)
export interface CategoryQueryParams {
search?: string;
page?: number;
limit?: number;
}
Step 4: Use in API Client
async getCategories(
userId: string,
queryParams?: CategoryQueryParams
): Promise<ApiResponse<PaginatedResponse<Category>>> {
// Implementation
}
Constitution Requirements
- FR-030: Typed TypeScript interfaces for all API calls ✅
- FR-037: TypeScript strict mode ✅
References
- Specification:
specs/002-frontend-todo-app/spec.md- Entity definitions - Plan:
specs/002-frontend-todo-app/plan.md- API contracts with types - Types File:
frontend/types/index.ts- Complete type definitions
Common Patterns Summary
- ✅ Use
interfacefor object types - ✅ Use
typefor union types (string literals) - ✅ Use generic types
<T>for reusable structures - ✅ Mark optional fields with
? - ✅ Match backend field names (snake_case for API responses)
- ✅ Use camelCase for form data types
- ✅ Create separate types for form data and query parameters
- ✅ Use descriptive names (EntityFormData, EntityQueryParams)
- ✅ Include all required fields from backend
- ✅ Provide default type parameters for generics (
<T = unknown>)