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

bug: Set a more lax (and dynamic) type for election.meta than object #213

Closed
elboletaire opened this issue Jul 5, 2023 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@elboletaire
Copy link
Member

Describe the bug

Current type for PublishedElection meta field is set to object, and this complicates things for end developers. Given we use a recursive key value object where values can be either strings or objects of the same type, I suggest setting a recursive type like

type ElectionMeta = {
  [key: string]: ElectionMeta | string
}

Note this should be properly tested since I'm not sure just setting it recursive in this way would work or not...

Current behavior

election.meta is of type object, forcing typescript developers to always use as any to properly access values:

const tokenDecimals = (election.meta as any).token.decimals

Expected behavior

To be able to access any election.meta subfield without requiring to add as any everytime:

const tokenDecimals = election.meta.token.decimals
@elboletaire elboletaire added the bug Something isn't working label Jul 5, 2023
marcvelmer added a commit that referenced this issue Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants