Skip to content

Move Attemptsfield to components and minor clean up#14059

Open
FinnIckler wants to merge 3 commits intothewca:mainfrom
FinnIckler:attempts-field-cleanup
Open

Move Attemptsfield to components and minor clean up#14059
FinnIckler wants to merge 3 commits intothewca:mainfrom
FinnIckler:attempts-field-cleanup

Conversation

@FinnIckler
Copy link
Copy Markdown
Member

I am pretty happy with the existing API, just moved the 4 repeating ifs to a record

if (number === SKIPPED_VALUE) return "";
if (number === DNF_VALUE) return "DNF";
if (number === DNS_VALUE) return "DNS";
const SPECIAL_VALUES: Partial<Record<number, string>> = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it Partial? You could declare type SpecialValue = SKIPPED_VALUE | DNF_VALUE | DNS_VALUE or something, and roll with that.

But anyways, isn't Record inherently partial? If I declare a Record<string, something>, then I don't have to map every single string in existence...

Comment on lines +64 to +66
Object.fromEntries(
Object.entries(SPECIAL_VALUES).map(([k, v]) => [v, Number(k)]),
) as Partial<Record<string, number>>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a Lodash helper for this?

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