Skip to content

[types] Accept revert and revert-layer, and fix six properties that accept no CSS-wide keywords - #1884

Draft
henryqdineen wants to merge 2 commits into
hqd-stylex-css-types-validatefrom
hqd-stylex-css-types-keywords
Draft

henryqdineen wants to merge 2 commits into
hqd-stylex-css-types-validatefrom
hqd-stylex-css-types-keywords

Conversation

@henryqdineen

Copy link
Copy Markdown
Collaborator

What changed / motivation ?

Two bugs, both found by the CSS-wide keyword test added in #1883.

revert and revert-layer were missing from every property. The all alias that 516 properties compose stopped at unset. revert has been Baseline since 2021 and revert-layer since 2022; csstype has carried both for years. Fixed in one place, since all is the single definition.

Six properties accepted none of the CSS-wide keywords — not even inherit. colorScheme: 'inherit' was a type error, as were marginTrim: 'unset', paintOrder, textJustify, WebkitBackgroundClip and WebkitBoxOrient. They were written null | 'a' | 'b' rather than all | 'a' | 'b'.

Linked PR/Issues

Stacked on #1883.

Additional Context

The cause of the second one is worth recording, because it explains why nobody noticed. Those six are the only properties in the file with no named type alias. Everything else declares type foo = … and writes foo?: all | foo; these inline their union at the property instead — and reaching for null, which is what all happens to start with, rather than composing all, is the slip that inlining hid. Five date to the initial commit; WebkitBackgroundClip was added later by "Chore: Allow additional -webkit- properties (#28)" and copied the shape.

Both fixes are pure widenings: no value that used to typecheck stops doing so. Confirmed after the change that color: 'revert-layer', colorScheme: 'inherit', marginTrim: 'unset' and paintOrder: 'revert' all compile.

The NO_GLOBAL_KEYWORDS allowlist that #1883 introduced for these six is deleted rather than shortened, so the pattern cannot come back.

Pre-flight checklist

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
yarn workspace v1.22.22
yarn run v1.22.22
$ node ./compare.js /tmp/tmp.jTxdgH0OOm /tmp/tmp.XJLoJ49fz0

Results Base Patch Ratio
@stylexjs/stylex/lib/cjs/stylex.js
· compressed 1,535 1,535 1.00
· minified 5,166 5,166 1.00
@stylexjs/stylex/lib/cjs/inject.js
· compressed 1,793 1,793 1.00
· minified 4,915 4,915 1.00
benchmarks/size/.build/bundle.js
· compressed 496,650 496,650 1.00
· minified 4,847,840 4,847,840 1.00
benchmarks/size/.build/stylex.css
· compressed 99,735 99,735 1.00
· minified 740,755 740,755 1.00
Done in 0.08s.
Done in 0.33s.

@henryqdineen
henryqdineen added this pull request to stack #1887 September 11, 2026 03:13
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

workflow: benchmarks/perf

Comparison of performance test results, measured in operations per second. Larger is better.
yarn workspace v1.22.22
yarn run v1.22.22
$ node ./compare.js /tmp/tmp.ELMk3rSzyK /tmp/tmp.9SGA6mf05I

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 593 596 1.01 +
· complex create 67 67 1.00
babel-plugin: stylex.createTheme
· basic themes 471 468 0.99 -
· complex themes 33 33 1.00
Done in 0.08s.
Done in 0.32s.

henryqdineen and others added 2 commits September 10, 2026 23:15
Worked example of the CSS-wide keyword loop: add the two missing keywords to
`GLOBAL_KEYWORDS`, and the test names every property that cannot take them.

    display: does not accept 'revert', 'revert-layer'. Either compose the
    `all` alias, or add it to NO_GLOBAL_KEYWORDS with a reason.

`revert` and `revert-layer` are CSS-wide keywords, valid on every property, but
the `all` alias that all 516 properties compose stopped at `unset`. `revert`
has been Baseline since 2021 and `revert-layer` since 2022; csstype has carried
both for years.

Fixed in one place, since `all` is the single definition. Pure widening -- no
value that used to typecheck stops doing so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Worked example of emptying an allowlist: delete `NO_GLOBAL_KEYWORDS` and the
test names each property and what it is missing.

    colorScheme: does not accept 'inherit', 'initial', 'unset', 'revert',
    'revert-layer'. Every property should compose the `all` alias.

These six were written `null | 'a' | 'b'` rather than `all | 'a' | 'b'`, so
they accepted none of the CSS-wide keywords -- `colorScheme: 'inherit'` was a
type error, as were `marginTrim: 'unset'`, `paintOrder`, `textJustify`,
`WebkitBackgroundClip` and `WebkitBoxOrient`.

They are also the only six properties in the file with no named type alias:
everything else declares `type foo = ...` and writes `foo?: all | foo`, while
these inline their union at the property. Reaching for `null` -- what `all`
happens to start with -- instead of composing `all` is the slip that inlining
hid. Five date to the initial commit; `WebkitBackgroundClip` was added later by
"Chore: Allow additional -webkit- properties (#28)" and copied the shape.

Pure widening. The allowlist is now gone rather than shortened, so nothing can
reintroduce the pattern.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@henryqdineen
henryqdineen force-pushed the hqd-stylex-css-types-keywords branch from a0dd0cd to 218d221 Compare September 11, 2026 03:15
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
stylex Ignored Ignored Sep 11, 2026 3:15am UTC

Request Review

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.

1 participant