Skip to content

Commit

Permalink
fix(object): the return type of objectMap should be the return type o… (
Browse files Browse the repository at this point in the history
  • Loading branch information
s3xysteak authored Jun 25, 2024
1 parent 6cc9a99 commit e751695
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import type { DeepMerge } from './types'
* // { b: 2 }
* ```
*/
export function objectMap<K extends string, V, NK = K, NV = V>(obj: Record<K, V>, fn: (key: K, value: V) => [NK, NV] | undefined): Record<K, V> {
export function objectMap<K extends string, V, NK extends string | number | symbol = K, NV = V>(obj: Record<K, V>, fn: (key: K, value: V) => [NK, NV] | undefined): Record<NK, NV> {
return Object.fromEntries(
Object.entries(obj)
.map(([k, v]) => fn(k as K, v as V))
.filter(notNullish),
)
) as Record<NK, NV>
}

/**
Expand Down

0 comments on commit e751695

Please sign in to comment.