realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Generic type for toJSON

Open thaynarbo opened this issue 2 years ago • 6 comments

Problem

In our application, we're using .toJSON a lot because we work with immutability and so we copy the data by using js spreading operation and when the spreading takes place the data is not available anymore, toJSON solves that problem. I wasn't seeing any problem with using toJSON for that matter, but after upgrading Realm to a newer version, I noticed that the type is returning something different Record<string, unknown>. Is there a way I could type it without having to force the type? The cast doesn't work here because they are a lot different.

image

from Realm types folder image

current realm version: 11.0.0 current react native version: 0.70.4 current typescript version: 4.8.3

Solution

It would be better if the type was generic instead of Record<string,unknown>

How important is this improvement for you?

Would be a major improvement

thaynarbo avatar Dec 07 '22 10:12 thaynarbo