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

WIP - Typing simplification #73

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

WIP - Typing simplification #73

wants to merge 4 commits into from

Conversation

ericboucher
Copy link
Collaborator

@ericboucher ericboucher commented Apr 24, 2023

This is a playground PR to explore ideas on how to simplify typing a bit for the different reports.

  1. I explored an option using the keys of the existing mapping.

  2. Another option would be to create a more complete mapping that could look somewhat like this and allow us to have additional key specific info in one place:

floodKeyMapping: {
    floodN: {
        name: 'floodN',
        koboKey: 'g2/flood_n',
        excludeByDefault: true,
		label: "Affected",
    }
}

The mapping above could help with translation with text labels, see: #76 (comment)

  1. Another option would be to instantiate the interface as a Class

Thoughts @sifelix ?

threat = 'threat',
other = 'other',
}

export const floodSpecificKeys = {
Copy link
Collaborator Author

@ericboucher ericboucher Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could have a better name I think. Maybe floodKoboKeyMapping or something like that @sifelix ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the name should definitively be updated :)

@ericboucher ericboucher changed the title WIP - Propose typing simplification WIP - Typing simplification Apr 24, 2023
@github-actions
Copy link

Build succeeded and deployed at https://wfp-dmp-73.surge.sh
(hash 710389f deployed at 2023-04-24T15:28:50)

},
{
...getGroupSetup('deathToll', FLOOD),
children: [
{ field: FloodSpecific.NumTDeath },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should continue to use the string Enum to avoid any typos

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This offers a check against typos as well. I proposed a few other option in the PR body. We can chat about it but it's not urgent anyway.

threat = 'threat',
other = 'other',
}

export const floodSpecificKeys = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the name should definitively be updated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants