Skip to content

Object.assign documentation and tests - #115

Closed
jmagaram wants to merge 2 commits into
rescript-lang:mainfrom
jmagaram:Object.assign-documentation
Closed

jmagaram wants to merge 2 commits into
rescript-lang:mainfrom
jmagaram:Object.assign-documentation

Conversation

@jmagaram

Copy link
Copy Markdown
Contributor

This took me a while because I wrote some tests to experiment and got the source and target mixed up - the mutable target goes first. Should we have labels on these?

I attempted to write code for assignMany but it doesn't work because you can't create an array of objects with different types. Well you can I guess if they start off as Object.empty() or are imported - jumping through hoops. Will this really get used? Do we need a toGenericObject function?

I couldnt' figure out the other flavor of assign with the json thing and what it does.

@zth zth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great!

Good point about assignMany. I think we can leave it undocumented for now. The Object module is for more specialized usage anyway.

docs for assignMany but no examples.
@glennsl

glennsl commented Mar 21, 2023

Copy link
Copy Markdown
Contributor

Adding assign2, assign3 etc. could be a good idea.

@glennsl

glennsl commented Mar 21, 2023

Copy link
Copy Markdown
Contributor

But you can also just chain calls to assign, so... 🤷

@jmagaram

Copy link
Copy Markdown
Contributor Author

Interesting idea on the assign2 assign3 - hadn't thought about that. I don't know when any of these functions will get used from ReScript, if ever. I wouldn't mind removing the assignMany and rely on chaining calls. A toUntypedObject could normalize objects in a list so assignMany will work. You all have much more real-world experience and know better what is needed here.

@jmagaram

Copy link
Copy Markdown
Contributor Author

Consolidated into #117

@jmagaram jmagaram closed this Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants