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: theme types #6423

Merged
merged 2 commits into from
Sep 26, 2022
Merged

fix: theme types #6423

merged 2 commits into from
Sep 26, 2022

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Work on #6358

Proposed Changes

Makes properties of the theme interfaces optional (since they are mostly optional).

This was tricky, because after the theme gets passed to the renderer, all of the properties should be "filled in". But trying to record this side-effect based change with types was going to be... difficult. So it's easier just to check that the renderer properly initialized the properties.

Behavior Before Change

External developers had to provide properties to themes they didn't want to override.

Should be no end-user-facing change in behavior.

Behavior After Change

Now you only need to provide the properties you want to override.

Should be no end-user-facing change in behavior.

Reason for Changes

Better dev experience.

Test Coverage

N/A

Documentation

N/A

Additional Information

N/A

@BeksOmega BeksOmega requested a review from a team as a code owner September 12, 2022 17:46
@BeksOmega BeksOmega requested a review from cpcallen September 12, 2022 17:46
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

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

I like the general approach, but dislike the repetitive throw statements.

My first thought was to just create a single function to do those checks, but then I realised that you could make it a type predicate for an InitialisedTheme type, and I don't think you even need to reference it explicitly in any of the functions which use it. (Though this might create inefficiency by checking more than just the single field that the caller is about to use—if the JIT does not optimise the checks away reliably.)

@BeksOmega
Copy link
Collaborator Author

Going to go ahead and merge due to release schedule. We can come back and add a type predicate later if desired.

@BeksOmega BeksOmega merged commit abad51f into google:develop Sep 26, 2022
@maribethb
Copy link
Contributor

I think an alternative way to solve this would be to change this line to use Partial<BlockStyles> which allows all the properties to be optional, while in all the code that uses BlockStyle the properties will now be required.

as a side note if that approach works then we should use the same type in this line as well

this is fine to fix as a follow up after this release though i think if we are crunched for time

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.

3 participants