Skip to content

Commit

Permalink
Merge branch 'main' into test-expectTypeOf
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Dec 21, 2023
2 parents 7958651 + c295e5a commit aaed0b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-onions-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hiogawa/utils": patch
---

Fix `objectMapValues` mapped type
5 changes: 2 additions & 3 deletions packages/utils/src/lodash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,8 @@ describe(`${objectMapValues.name}/${objectMapKeys.name}`, () => {
const result = objectMapValues(o, (v, k) => (v ? k.repeat(v) : "bad-v"));
expectTypeOf(result).toEqualTypeOf<{
x: string;
// TODO: these should be optional
y: string;
z: string;
y?: string;
z?: string;
}>();
expect(result).toMatchInlineSnapshot(`
{
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/lodash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function objectMapEntries<T extends object, K2 extends PropertyKey, V2>(
export function objectMapValues<T extends object, V>(
o: T,
f: (v: T[keyof T], k: keyof T) => V
): Record<keyof T, V> {
): { [k in keyof T]: V } {
return objectMapEntries(o, ([k, v]) => [k, f(v, k)]);
}

Expand Down

0 comments on commit aaed0b8

Please sign in to comment.