DeepOmit
Since 1.1.0
Remove properties at nested paths.
Signature
typescript
type DeepOmit<T, P extends string> = T extends object
? P extends ''
? T
: DeepOmitBySegments<T, PathSegments<T, P>>
: TParameters
| Parameter | Description |
|---|---|
T | The target object type |
P | The path to omit |
Description
Removes properties at specified nested paths from an object type.
Examples
Basic Usage
typescript
import type { DeepOmit } from 'uni-types'
interface User {
profile: {
name: string
email: string
settings: {
theme: string
lang: string
}
}
}
type WithoutSettings = DeepOmit<User, 'profile.settings'>
// { profile: { name: string; email: string } }Single Property
typescript
interface Config {
database: {
host: string
port: number
password: string
}
}
type SafeConfig = DeepOmit<Config, 'database.password'>
// { database: { host: string; port: number } }