Skip to content

better type for Record.toJS#1917

Merged
jdeniau merged 4 commits intomainfrom
ts-toJS
Dec 22, 2022
Merged

better type for Record.toJS#1917
jdeniau merged 4 commits intomainfrom
ts-toJS

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.

2 participants