feat(typescript-types): Add Assign<Shape,Defaults,Obj>
This commit is contained in:
9
packages/typescript-types/src/assign.ts
Normal file
9
packages/typescript-types/src/assign.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { OptionalKeysOf } from './optional-keys-of.js'
|
||||
|
||||
export type Assign<
|
||||
Shape extends object,
|
||||
Defaults extends Pick<Required<Shape>, OptionalKeysOf<Shape>>,
|
||||
Obj extends Shape
|
||||
> = {
|
||||
[K in keyof Shape]: K extends keyof Obj ? Obj[K] : K extends keyof Defaults ? Defaults[K] : never
|
||||
}
|
||||
Reference in New Issue
Block a user