Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): better enumValues type #3211

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading