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

refactor: Add Override type #14248

Merged
merged 3 commits into from
Dec 9, 2024
Merged

refactor: Add Override type #14248

merged 3 commits into from
Dec 9, 2024

Conversation

TomasEng
Copy link
Contributor

@TomasEng TomasEng commented Dec 9, 2024

Description

Created a utility type named Override for merging two types together with the following signature:

type Override<Primary, Secondary> = Primary & Omit<Secondary, keyof Primary>

The type accepts two type arguments, where the keys of the second type will be overridden by the keys of the first type when they have the same name. This eliminates the need to explicitly Omit the keys of the second type.

Example:

type Merged = Override<
  {
    key0: number,
    key1: number
  },
  {
    key1: string,
    key2: string
  }
>;

corresponds to

type Merged = {
  key0: number,
  key1: number, // number because key1 in the first type is number and overrides key1 in the second type
  key2: string
}

This type will be used in the code list editor, but I have also imported it in some places where it can be used already.

Related Issue

Verification

  • Your code builds clean without any errors or warnings

@TomasEng TomasEng changed the title Add Override type refactor: Add Override type Dec 9, 2024
@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Dec 9, 2024
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (9f43969) to head (424f648).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14248   +/-   ##
=======================================
  Coverage   95.52%   95.52%           
=======================================
  Files        1817     1817           
  Lines       23700    23700           
  Branches     2749     2749           
=======================================
  Hits        22640    22640           
  Misses        807      807           
  Partials      253      253           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TomasEng TomasEng marked this pull request as ready for review December 9, 2024 08:47
@TomasEng TomasEng added team/studio-domain1 quality/code Violations from current rules for code, best practices, etc. Or just bad code. skip-releasenotes Issues that do not make sense to list in our release notes skip-manual-testing PRs that do not need to be tested manually skip-documentation Issues where updating documentation is not relevant labels Dec 9, 2024
@standeren standeren self-assigned this Dec 9, 2024
Copy link
Contributor

@standeren standeren left a comment

Choose a reason for hiding this comment

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

Clean code and nice PR description. Nothing to point out here ✨

@standeren standeren removed their assignment Dec 9, 2024
@standeren standeren merged commit 61f7546 into main Dec 9, 2024
10 checks passed
@standeren standeren deleted the add-override-type branch December 9, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend quality/code Violations from current rules for code, best practices, etc. Or just bad code. skip-documentation Issues where updating documentation is not relevant skip-manual-testing PRs that do not need to be tested manually skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants