Repository navigation
fix(types): type CSS custom properties against what both platforms honour - #423
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
This was referenced Aug 15, 2026
Contributor
Author
…nour vars() and VariableContextProvider were typed Record<string, string | number> on web and Record<string, StyleDescriptor> on native, and a consumer only sees the web declarations, since the root entry's types re-export ./web. A font-family list or an undefined entry was a type error though native takes both, while StyleDescriptor admits var() tuples and null that web cannot serialise: web's vars() threw on undefined and null, and its provider passed raw values into the style. CustomPropertyValue is the set both platforms honour: a string, a number, a boolean, undefined, or an array of those, which is a comma-separated list. Both platforms type vars() and VariableContextProvider with it, and web serialises through one function that leaves an undefined value unset. A type-level fixture holds the three entries to one type, and the README shows the provider by its current name.
YevheniiKotyrlo
force-pushed
the
fix/vars-descriptor-types
branch
from
October 11, 2026 12:35
151b46c to
84c1f23
Compare
This was referenced Oct 11, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
vars()and<VariableContextProvider />are typed twice, and neither type is the set of values both implementations honour:Record<string, string | number>.Record<string, StyleDescriptor>.A consumer only ever sees the web types, because the root entry's declarations re-export
./weband nothing selects the native ones.vars({ "--font-stack": ["Inter", "Helvetica"] })andvars({ "--color": undefined })are type errors, though native honours both. Insrc/__tests__/native/vars.test.tsx, jest resolves the native runtime andtscthe web types, so the same file passes under one and fails under the other.StyleDescriptoradmitsundefined,nulland the compiler'svar()tuples. Onmain, web'svars()throws onundefinedandnull, and stringifies a tuple as[object Object],var,y.<div>'s style.Solution
CustomPropertyValueis the set both platforms honour: a string, a number, a boolean,undefined, or an array of those, which is a comma-separated list.vars()andVariableContextProviderwith it.undefinedvalue unset and drops anundefinedlist member.Tests
src/__tests__/_custom-property-value.types.tsis type-level and runs underyarn typecheck:null, an object, avar()tuple and the wholeStyleDescriptorare rejected.src/__tests__/web/variables.test.tsx: web serialisation of lists, booleans andundefined, throughvars()and the provider.src/__tests__/native/vars.test.tsx: a list and anundefinedvalue reach the native runtime as typed.main, 4 of the 5 web cases fail, and the native cases fail undertsc. Each of 4 mutations fails its own cases, and addingnullto the type fails the typecheck.Verification
On Windows with Node 26:
yarn lintcleanyarn typecheckcleanyarn test --coverage: every failure also fails onmainon this machine (the four babel cases)yarn buildcleanyarn example expo export --platform webexportedMerge order
#431 changes native
vars()on the same line, so whichever lands second takes both changes.It also shares lines with #412 (
__tests__/native/vars.test.tsx,native-internal/variables.tsx), #443 (__tests__/native/vars.test.tsx), #469 (__tests__/native/vars.test.tsx); whichever lands second rebases.Base
Re-written on
main(a5002c5), where nativevars()declares itsViewStylereturn, which this keeps.