Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Cannot able create a Record from another Record (With all optional keys)

$
0
0

Apologies for missing your reply earlier.

I’m creating a JSX using the generic JSX feature of ReScript. We have a native cross-platform renderer that requires a prop in string format. However, I don’t want developers to write margins in string format like “20,20,20,20”. To address this, I’ve defined two prop types:

type margin = Margin(int, int, int, int)
type props = {key?: string, margin?: margin}

type renderProps = {key?: string, margin?: string}

Now, I need a mapper function to convert between these types. However, I encountered an issue where all keys were converting to undefined. My native renderer checks for the presence of props using hasOwnProperty and other contracts. I don’t want to change my native renderer, and I also dislike the idea of writing a JavaScript loop to remove all keys with undefined values.

I’m unable to think of any solution from the ReScript side either…


Viewing all articles
Browse latest Browse all 2592

Trending Articles