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

Style engine: update type for getCSSValueFromRawStyle #64528

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Aug 15, 2024

What?

Follow up to #64490

Use a generic type parameter StyleValue to describe argument and return value of getCSSValueFromRawStyle().

Props to @kevin940726

Why?

Avoid the use of any and describe better what the function expects.

How?

By default, StyleValue is set to string. This allows the function to be flexible with the type of styleValue, but it defaults to handling strings.

getCSSValueFromRawStyle() takes one parameter, styleValue, which is of type StyleValue = string. This means it can be any type, but the function is primarily designed to work with strings.

getCSSValueFromRawStyle() returns a value of the same type StyleValue. This ensures that its output type matches its input type.

Testing Instructions

The CI should build, all tests should pass.

… By default, T is set to string. This allows the function to be flexible with the type of styleValue, but it defaults to handling strings.
@ramonjd ramonjd added [Type] Code Quality Issues or PRs that relate to code quality [Package] Style Engine /packages/style-engine labels Aug 15, 2024
@ramonjd ramonjd requested a review from kevin940726 August 15, 2024 04:16
@ramonjd ramonjd self-assigned this Aug 15, 2024
Copy link

github-actions bot commented Aug 15, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <[email protected]>
Co-authored-by: kevin940726 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@kevin940726 kevin940726 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

packages/style-engine/README.md Outdated Show resolved Hide resolved
Update utils.ts - change type to StyleValue
@ramonjd ramonjd force-pushed the fix/style-engine-function-css-value-typing branch from b42393f to 44de688 Compare August 15, 2024 05:36
@ramonjd ramonjd enabled auto-merge (squash) August 15, 2024 05:37
Copy link

Flaky tests detected in 44de688.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10399358112
📝 Reported issues:

@ramonjd ramonjd merged commit 38c233f into trunk Aug 15, 2024
60 checks passed
@ramonjd ramonjd deleted the fix/style-engine-function-css-value-typing branch August 15, 2024 06:12
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Style Engine /packages/style-engine [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants