名称: TypeScript 描述: TypeScript 配置、严格模式、泛型和类型工具。 允许的工具: 读取、写入、编辑、Bash、Glob、Grep
TypeScript 技能
提供 TypeScript 配置和模式方面的专家级协助。
能力
- 配置 tsconfig
- 实现严格类型检查
- 创建实用工具类型
- 处理泛型
- 设计类型安全的 API
配置
// tsconfig.json
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "bundler",
"esModuleInterop": true,
"skipLibCheck": true
}
}
实用工具类型
// Extract, Omit, Pick
type 无密码用户 = Omit<用户, 'password'>;
// 条件类型
type 非空类型<T> = T extends null | undefined ? never : T;
// 映射类型
type 只读<T> = { readonly [P in keyof T]: T[P] };
目标流程
- typescript-设置
- 类型安全
- api-设计