Skip to content

Commit

Permalink
fix(store): better enumValues type (#3211)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Sep 20, 2024
1 parent d21c1d1 commit a08ba5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-gifts-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": patch
---

Improved config output type of `enumValues`.
2 changes: 1 addition & 1 deletion packages/store/ts/config/v2/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function resolveEnums<enums extends EnumsInput>(enums: enums): resolveEnu

export type mapEnums<enums> = {
readonly [key in keyof enums]: {
readonly [element in keyof enums[key] as enums[key][element] & string]: parseNumber<element>;
readonly [element in keyof enums[key] & `${number}` as enums[key][element] & string]: parseNumber<element>;
};
};

Expand Down
7 changes: 6 additions & 1 deletion packages/store/ts/config/v2/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,12 @@ describe("defineStore", () => {
First: 0,
Second: 1,
},
});
}).type.toString.snap(`{
readonly Example: {
readonly First: 0
readonly Second: 1
}
}`);
});

it("should allow a const config as input", () => {
Expand Down

0 comments on commit a08ba5e

Please sign in to comment.