facebook / react-strict-dom

React Strict DOM (RSD) is a subset of React DOM, imperative DOM, and CSS that supports web and native targets
MIT License
2.95k stars 151 forks source link

Flow type support for data-* props #71

Open necolas opened 1 month ago

necolas commented 1 month ago

Describe the feature request

Flow doesn't have support for typing arbitrary data-* props. This requires RSD to add Meta-specific data-* props on an as-needed basis, and each time it is considered a "blocker" by the team migrating components to RSD. This creates incentives to either 1) patch internally generated RSD syncs with new Flow types (complicates syncs, can cause regressions), or 2) add Meta-specific props to the OSS project code (doesn't scale to other users).

cc @jbrown215 who had ideas on how to support this from the Flow side

nmn commented 1 month ago

While we wait for the Flow team to prioritise and implement the Template Literal Types feature, a stop gap solution would be to create a separate file just for the data-* properties and split it out from StrictReactDOMProps.

This will avoid the need for patch files when we try to maintain a list of props used internally.

We can also shadow this file with a .d.ts file which uses template literal types so Typescript users don't have to deal with this Flow limitation.