You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c877f5c
Browse filesBrowse the repository at this point in the historyBrowse files
Type-safe props, events, and refs for react-strict-dom (#504)
* Type event-handler props instead of $FlowFixMe
The event props on the Strict* prop types were all $FlowFixMe, so handlers
got no checking and authors got no autocomplete. Add StrictReactDOMEvents
with the event shapes the native factories actually build (change, input,
key, click, image load/error) and a StrictOpaqueEventHandler for the
pass-through handlers whose runtime shape is platform-specific.
Wire those through StrictReactDOMProps and the button/image/input/select/
textarea prop types, and re-export the payload types from the native and
web entrypoints so consumers can annotate their own handlers.
* Clear out the $FlowFixMe in the native renderer
Type the props the native modules build and drop the suppressions that were
hiding the gaps. The prop mutation that the factories do (role defaults,
display:block emulation, the hidden polyfill) moves out of the hook bodies
into plain helpers so it can write to the caller-owned nativeProps without
tripping react-rule-hook-mutation.
Route HostInstance through the renderer.native type boundary rather than
importing it from 'react-native' in each module, matching how the runtime
already funnels RN access through the local wrapper.
Two suppressions are left in place on purpose: the skew check in
useStyleTransition and the provideInheritableStyle comparison both sit on top
of latent behavior bugs, so the fixes (and the type cleanup that goes with
them) land in a separate PR rather than riding along with a types-only change.
* Drop the $FlowFixMe in the web runtime
The default style table cast every entry with $FlowFixMe[incompatible-type];
the types line up now, so the casts are gone. For the debug-style object that
stylex.create does not generate, use a small local DebugCompiledStyle type
instead of an unclear-type cast.
The one suppression left on validateStrictProps stays, with a note on why:
typing the argument precisely would block the in-place delete of invalid keys
that the function relies on.
* Add Flow tests for the tightened prop and ref types
Now that the props are typed, pin the behaviour down. refs-and-props covers
the host-element ref types and the props that should be accepted;
expected-errors locks in the misuse Flow has to reject, so a future loosening
of the types fails here instead of slipping through. Extend html-types-match
with the new event payload types.
---------
Co-authored-by: Yamin Yassin <Yamin.Yassin+CAG@cagtechhub.com>
0 commit comments