Skip to content

[babel-plugin] add constKey/constVal to Rule type#1696

Merged
mellyeliu merged 1 commit into
facebook:mainfrom
henryqdineen:hqd-rule-type-const-fields
Jun 4, 2026
Merged

[babel-plugin] add constKey/constVal to Rule type#1696
mellyeliu merged 1 commit into
facebook:mainfrom
henryqdineen:hqd-rule-type-const-fields

Conversation

@henryqdineen
Copy link
Copy Markdown
Collaborator

What changed / motivation ?

The hand-written packages/@stylexjs/babel-plugin/src/index.d.ts types a Rule's object as { ltr: string; rtl?: null | string }, but the Flow source (src/index.js) also declares optional constKey / constVal (used by defineConsts rules). Consumers reading the rule objects passed to processStylexRules can't access those fields without casting.

This adds constKey? / constVal? to the .d.ts so it matches the Flow source of truth.

Linked PR/Issues

Extracted from #1322, which bundles this same fix into a broader CJS-compat restructure — pulling the type change out so it can land on its own.

Additional Context

Type-only change. prettier --check passes, and the added fields match the existing Flow Rule type in src/index.js.

Pre-flight checklist

The hand-written src/index.d.ts types a Rule's object as
`{ ltr: string; rtl?: null | string }`, but the Flow source (src/index.js)
also has optional `constKey` / `constVal` (used by defineConsts rules).
Consumers that read the rule objects returned to processStylexRules can't
access those fields type-safely without casting. Add them to match the
source of truth.

Extracted from the broader CJS-compat change in facebook#1322 so the type fix can
land on its own.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 3, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@henryqdineen is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

henryqdineen added a commit to henryqdineen/stylex that referenced this pull request Jun 3, 2026
Resolve conflicts to keep this PR's CJS-compat (export =) restructure on
top of current main. Uses main's current processStylexRules config (the
useLayers object form) and leaves the Rule constKey/constVal fields to
the separate facebook#1696, so the two PRs stay orthogonal.
@mellyeliu mellyeliu merged commit b571285 into facebook:main Jun 4, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants