Built-in TypeScript utility types and their applications
View on GitHubplugins/aai-stack-typescript/skills/typescript-utility-types/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-stack-typescript/skills/typescript-utility-types/SKILL.md -a claude-code --skill typescript-utility-typesInstallation paths:
.claude/skills/typescript-utility-types/# TypeScript Utility Types Skill
Comprehensive guide to TypeScript's built-in utility types.
## Property Modifiers
### Partial<T>
Makes all properties optional.
```typescript
interface User {
id: string
name: string
email: string
}
type PartialUser = Partial<User>
// { id?: string; name?: string; email?: string }
// Use case: Update functions
function updateUser(id: string, updates: Partial<User>): User {
const user = getUser(id)
return { ...user, ...updates }
}
updateUser('123', { name: 'New Name' }) // Only update name
```
### Required<T>
Makes all properties required.
```typescript
interface Config {
host?: string
port?: number
timeout?: number
}
type RequiredConfig = Required<Config>
// { host: string; port: number; timeout: number }
// Use case: Ensure all config is provided
function initServer(config: RequiredConfig): void {
// All properties guaranteed to exist
console.log(`Server at ${config.host}:${config.port}`)
}
```
### Readonly<T>
Makes all properties readonly.
```typescript
interface State {
count: number
users: string[]
}
type ReadonlyState = Readonly<State>
// { readonly count: number; readonly users: string[] }
const state: ReadonlyState = { count: 0, users: [] }
// state.count = 1 // Error: Cannot assign to 'count'
// Note: Only shallow - arrays can still be mutated
// state.users.push('new') // This still works!
// For deep readonly, use custom type or library
type DeepReadonly<T> = {
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P]
}
```
## Property Selection
### Pick<T, K>
Creates type with only selected properties.
```typescript
interface User {
id: string
name: string
email: string
password: string
createdAt: Date
}
type UserPreview = Pick<User, 'id' | 'name'>
// { id: string; name: string }
// Use case: API response types
type PublicUser = Pick<User, 'id' | 'name' | 'email'>
function getPublicProfile(user: User): PublicUser {
return {
id: user.id,