Skip to content

Commit

Permalink
Fixed assignWithDefaults type
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Apr 19, 2024
1 parent 93b7d75 commit 4d77d60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function omit<T extends object, K extends keyof T>(object: T, ...keys: re
return filterObject<T, Omit<T, K>>(object, (key: K) => !keys.flat().includes(key));
}

export function assignWithDefaults<To extends object, From extends Partial<To>>(to: To, from: From, defaults: Partial<To> = to): void {
export function assignWithDefaults<To extends object, From extends object>(to: To, from: From, defaults: Partial<To> = to): void {
const keys = new Set([...Object.keys(to), ...Object.keys(from)]);
for (const key of keys) {
to[key] = from[key] ?? defaults[key] ?? to[key];
Expand Down

0 comments on commit 4d77d60

Please sign in to comment.