-
Notifications
You must be signed in to change notification settings - Fork 348
Open
Labels
Description
I wanted to open a discussion on a possible way forward to add spread props
If we required users to specify the type of the spread props (assume in the same file for now), it might be possible to have the PPX transform the following,
type exampleSpeadProps = {
someProp: string,
someOtherProp: string,
}
[@react.component]
let example = (~someComponentProp, [@react.rest] exampleSpreadProps) =>
<div
someComponentProp
[@react.spead] exampleSpreadProps
/>into
[@react.component]
let example = (~someComponentProp, ~someProp: string, ~someOtherProp: string) =>
<div
someComponentProp
someProp
someOtherProp
/>This should preserve type safety and enable spreading
It'll also have the added benefit that you could use multiple rest/spread types (assuming no names overlap), and spread them to different child elements
It might also be possible to define the types in a different file if we leveraged some of the code from ppx-import
ersinakinci, Faliszek and digression99