On this page
Omit
Prev: `Pick` | Up: object_transforms | Next: union_and_nullability
Rel: object_transforms, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #object_transforms #tier/core
Syntax & Overview
Omit<T, Keys>
Constructs a type with all properties of T except Keys.
Notes & Pitfalls
- Creates a type with specified keys removed: Note that
Omit<T, K>does not error on misspelled keys inK(unlikePick), and distributes poorly over unions unless wrapped in a distributive helper.
Example
interface User { id: number; name: string; passwordHash: string }
type PublicUser = Omit<User, "passwordHash">;
const pub: PublicUser = { id: 1, name: "Ada" };
Linked from
Related notes
- tuts/typescript/utility_types/object_transforms/Pick Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/object_transforms Linked here; links to this page; shared tags: #typescript, #web
- tuts/typescript/type_system/conditional_and_mapped_types Linked here; shared tags: #typescript, #web
- tuts/typescript/utility_types/union_and_nullability Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #tier, #typescript, #web