Skip to content

Style Engine: Export public TypeScript types#79079

Merged
senadir merged 4 commits into
WordPress:trunkfrom
ralucaStan:add/style-engine-type-exports
Jun 10, 2026
Merged

Style Engine: Export public TypeScript types#79079
senadir merged 4 commits into
WordPress:trunkfrom
ralucaStan:add/style-engine-type-exports

Conversation

@ralucaStan

@ralucaStan ralucaStan commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What?

Re-exports the Style, StyleOptions, and GeneratedCSSRule types from the @wordpress/style-engine entry point so consumers can type their usage of compileCSS and getCSSRules.

Why?

The package ships a types field but src/index.ts only exported the two functions, not the types in their signatures. Consumers work around this by deep-importing from source (e.g. WooCommerce imports from @wordpress/style-engine/src/types), which is fragile and not part of the published API. Other TS packages like @wordpress/rich-text and @wordpress/components already export their public types this way.

How?

  • Added documented export type statements in src/index.ts for the three public-signature types (internal helpers stay unexported).
  • Added JSDoc so the autogenerated API docs render descriptions; regenerated README.md and added a CHANGELOG entry.

Testing Instructions

  1. Run npx tsc --build packages/style-engine/tsconfig.json — completes without errors.
  2. Confirm packages/style-engine/build-types/index.d.ts re-exports Style, StyleOptions, and GeneratedCSSRule.
  3. import type { Style, StyleOptions, GeneratedCSSRule } from '@wordpress/style-engine'; resolves without errors.

Testing Instructions for Keyboard

N/A — types-only, no UI changes.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the [Package] Style Engine /packages/style-engine label Jun 10, 2026
Re-export the `Style`, `StyleOptions`, and `GeneratedCSSRule` types from the
package entry point so consumers of `@wordpress/style-engine` can type their
usage of `compileCSS` and `getCSSRules`. These are the types that appear in
the public function signatures; internal helper types remain unexported,
matching the convention used by `rich-text` and `components`.

Each exported type is documented at the export site so the autogenerated API
docs render a description, and the README is regenerated accordingly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@ralucaStan ralucaStan force-pushed the add/style-engine-type-exports branch from 92f2a01 to 9472c69 Compare June 10, 2026 10:27
@ralucaStan ralucaStan marked this pull request as ready for review June 10, 2026 10:37
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

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: ralucaStan <[email protected]>
Co-authored-by: senadir <[email protected]>

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

@senadir senadir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking fine apart the duplication in docs and maybe we need to run some sort or docs update script?

Comment thread packages/style-engine/src/index.ts
@senadir senadir added the [Type] Enhancement A suggestion for improvement. label Jun 10, 2026
@ralucaStan ralucaStan force-pushed the add/style-engine-type-exports branch from 9472c69 to 48a66d4 Compare June 10, 2026 11:04
Use a concise summary at each export (which docgen renders into the README)
and a fuller description at each type definition (which IDE tooling surfaces
on hover), so the two are no longer identical. Matches the pattern used by
the `rich-text` and `worker-threads` packages.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@ralucaStan ralucaStan force-pushed the add/style-engine-type-exports branch from 48a66d4 to d1f2120 Compare June 10, 2026 11:08
ralucaStan and others added 2 commits June 10, 2026 13:22
The `Style` interface gained a top-level `background` key; reword its
definition comment to mention backgrounds and phrase the property list as
non-exhaustive ("such as") so it stays accurate as the type evolves.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Document both functions with an @example JSDoc block so docgen renders a
Usage example into the README's autogenerated API section. This makes the
exported Style, StyleOptions and GeneratedCSSRule types learnable in context
(selector vs. inline output, structured rules), with the example colocated
with the code as a single source of truth rather than hand-written README
prose. Outputs were verified against the package's behaviour.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@ralucaStan ralucaStan requested a review from senadir June 10, 2026 11:43
@senadir senadir merged commit 2c4461a into WordPress:trunk Jun 10, 2026
41 of 42 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 10, 2026
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] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants