← スキル一覧に戻る

typescript
by laulauland
⭐ 0🍴 0📅 2026年1月22日
SKILL.md
name: typescript description: TypeScript coding conventions and best practices. Use when working with TypeScript files, defining types, or setting up TypeScript projects.
TypeScript Guidelines
Type System Usage
- Use TypeScript for all code
- Prefer interfaces over types for object definitions
- Avoid enums; use const objects with 'as const' assertion
// Prefer:
const UserRole = {
ADMIN: 'ADMIN',
USER: 'USER',
} as const;
type UserRole = typeof UserRole[keyof typeof UserRole];
// Avoid:
enum UserRole {
ADMIN = 'ADMIN',
USER = 'USER',
}
Type Safety Rules
- Define strict types for all message passing between components
- Use explicit return types for all functions
- Use functional components with TypeScript interfaces
interface Props {
user: UserProfile;
onUpdate: (user: UserProfile) => void;
}
function UserComponent ({ user, onUpdate }: Props): JSX.Element {
// ...
};
Schema Libraries for Data Modeling
When a project uses a schema library (Zod, Effect Schema, Valibot, etc.), prefer using it for data modeling over plain TypeScript types:
// If project uses Zod, prefer:
const User = z.object({
id: z.string().uuid(),
email: z.string().email(),
role: z.enum(['admin', 'user']),
});
type User = z.infer<typeof User>;
// Over plain TypeScript:
interface User {
id: string;
email: string;
role: 'admin' | 'user';
}
Benefits:
- Runtime validation at system boundaries
- Single source of truth (schema derives type)
- Automatic parsing and transformation
- Better error messages
Import and Error Handling
- Avoid try/catch blocks unless error translation is needed at that level
- If needed, prefer using
tryCatch/tryCatchAsyncutility functions that return errors or data
import { UserService } from '@/services/user';
import { Logger } from '@/utils/logger';
スコア
総合スコア
40/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です