Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better type for Record.toJS #1917

Merged
merged 4 commits into from Dec 22, 2022
Merged

better type for Record.toJS #1917

merged 4 commits into from Dec 22, 2022

Conversation

jdeniau
Copy link
Member

@jdeniau jdeniau commented Dec 19, 2022

Record.toJS loose the Record type and return something like:

Actually the following code:

Record({ keyA: 'a', keyB: 'b' });

will return this type.

{
    keyA: unknown,
    keyB: unknown,
}

This PR implement the DeepCopy functionnality to handle the deep convertion made by toJS

It will now return this:

{
    keyA: string,
    keyB: string,
}

It does handle recursive types:

type NestedObject = Record({ map: Map<string, string>(); list: List<string>(); set: Set<string>() });
// type will be : { map: { [key: string]: string }; list: string[]; set: string[]; }

@jdeniau jdeniau merged commit ffb3ee8 into main Dec 22, 2022
@jdeniau jdeniau deleted the ts-toJS branch December 22, 2022 15:25
@leebyron
Copy link
Collaborator

This is so good

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.

None yet

2 participants