react-strict-dom icon indicating copy to clipboard operation
react-strict-dom copied to clipboard

Flow type support for data-* props

Open necolas opened this issue 1 year ago • 1 comments

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

necolas avatar Apr 03 '24 18:04 necolas

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.

nmn avatar Apr 04 '24 09:04 nmn