writing-types
为 Next.js 编写 TypeScript 类型
手动编写 TypeScript 类型容易出错,并可能导致代码库中的模式不一致。本技能提供创建模块化、可维护类型定义的指南,以提高代码质量和类型安全性。
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "writing-types". Write types for a product with id, name, price, description, and category
النتيجة المتوقعة:
- ```typescript
- // types/product.ts
- export type ProductId = string;
- export interface Product {
- id: ProductId;
- name: string;
- price: number;
- description: string;
- category: string;
- }
- ```
استخدام "writing-types". Create types for a user profile with optional avatar and required email
النتيجة المتوقعة:
- ```typescript
- // types/user.ts
- export interface UserProfile {
- id: string;
- email: string;
- displayName: string;
- avatarUrl?: string;
- createdAt: Date;
- }
- ```
التدقيق الأمني
آمنAll static findings are false positives. The SKILL.md file contains only markdown documentation with inline code formatting. Backticks are used for path references, not shell execution. No cryptographic algorithms, network calls, or dangerous code patterns present.
مشكلات متوسطة المخاطر (2)
درجة الجودة
ماذا يمكنك بناءه
新数据模型类型
向 Next.js 应用程序添加新数据模型时,使用此技能生成遵循项目约定的干净、模块化类型定义。
API 响应类型
通过描述期望的数据结构为 API 响应创建类型定义。该技能帮助将类型组织成可管理的文件。
重构遗留类型
分解大型类型文件时,使用此技能将类型重构为更小的、专注的模块,同时保持类型安全性。
جرّب هذه الموجهات
Write TypeScript types for a user object with the following properties: id, name, email, createdAt. Keep it modular and follow the writing-types skill guidelines.
Create type definitions for a paginated API response that includes items array, total count, page number, and hasMore flag. Use separate files if the types exceed 50 lines.
Write types for a blog post that includes an author reference, tags array, and nested comments. Separate the types into modular files following the skill rules.
Generate all TypeScript types needed for a todo list feature including Todo, TodoList, and UserTodoPreferences. Organize them into modular files under the types directory.
أفضل الممارسات
- 使用描述性的类型名称并将关注点分离到模块化文件中
- 将每个类型文件保持在 50 行以内以提高可维护性
- 从 index 文件导出类型以便于导入
تجنب
- 将所有类型放在一个单一的 monolithic types.ts 文件中
- 使用过于通用的类型如 'any' 或 'object'
- 定义复杂的嵌套类型而不将其分解成更小的部分