On this page
Partial
Prev: object_transforms | Up: object_transforms | Next: `Required`
Rel: object_transforms, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #object_transforms #tier/core
Syntax & Overview
Partial<T>
Marks every property of T optional (?).
Notes & Pitfalls
- Shallowly marks all top-level properties optional: Ideal for
update(id, patch: Partial<User>)payloads.
Example
interface Settings { host: string; port: number }
function mergeSettings(base: Settings, patch: Partial<Settings>): Settings {
return { ...base, ...patch };
}
Linked from
Related notes
- tuts/typescript/utility_types/object_transforms/Required 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/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
- tuts/typescript/builtins/keyof shared tags: #tier, #typescript, #web