OverrideProperties<TOriginal, TOverride>
OverrideProperties<
TOriginal
,TOverride
> =Merge
<TOriginal
,TOverride
>
Defined in: packages/react-querybuilder/src/types/type-fest/override-properties.ts:26
Override existing properties of the given type. Similar to Merge
, but enforces that the original type has the properties you want to override.
This is useful when you want to override existing properties with a different type and make sure that these properties really exist in the original.
Type Parameters
Type Parameter |
---|
TOriginal |
TOverride extends Partial <Record <keyof TOriginal , unknown >> & { [Key in keyof TOverride]: Key extends keyof TOriginal ? TOverride[Key] : never } |
Example
type Foo = {
a: string
b: string
}
type Bar = OverrideProperties<Foo, {b: number}>
//=> {a: string, b: number}
type Baz = OverrideProperties<Foo, {c: number}>
// Error, type '{ c: number; }' does not satisfy the constraint '{ c: never; }'
type Fizz = OverrideProperties<Foo, {b: number; c: number}>
// Error, type '{ b: number; c: number; }' does not satisfy the constraint '{ b: number; c: never; }'
caution
API documentation is generated from the latest commit on the main
branch. It may be somewhat inconsistent with official releases of React Query Builder.