TypeScript 7 · Utility types and narrowing
Pick or omit properties
Create a type from a subset of another type's properties.
type UserSummary = Pick<User, "id" | "name">;
type NewUser = Omit<User, "id">;
Official TypeScript 7 documentation
More utility types and narrowing commands
- Make all properties optional
- Type a dictionary
- Require or freeze properties
- Remove null and undefined
- Write a type guard
- Narrow an unknown value
All utility types and narrowing commands · TypeScript 7 cheatsheet