目录
Yamin Yassin

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

1个月前380次提交

react-strict-dom dev

Action status

Development monorepo for “React Strict DOM”.

React Strict DOM (RSD) standardizes the development of styled React components for web and native. The goal of RSD is to improve the speed and efficiency of React development without compromising on performance, reliability, or quality. Building with RSD is helping teams at Meta ship features faster, to more platforms, with fewer engineers.

Structure

Contributing

Learn more about how to contribute.

Code of conduct

This project expects all participants to adhere to Meta’s OSS Code of Conduct. Please read the full text so that you can understand what actions will and will not be tolerated.

License

React Strict DOM is MIT licensed.

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号