shakilsiraj / json-object-mapper

A TypeScript library to serialize and deserialize object graph from/to JSON in a fast and non-recursive way
MIT License
58 stars 18 forks source link

Show warning if @CacheKey is not present for custom serializer/deserializer #36

Open ingver opened 5 years ago

ingver commented 5 years ago

Hello!

I ran into a problem today, when my production build was throwing misterious errors like t.map is not a function. Spent some hours to localize an issue, then figured out that the reason was deserializers caching strategy, which doesn't work after minification. I've done some research and have read #2. @CacheKey was the solution. I consider it strange, that the problem isn't mentioned in the documentation.

Thus, I wanted to suggest an improvement. The library could warn about missing @CacheKey decorator, so developer would not occasionally shoot himself in the foot on production.

Fattouh92 commented 5 years ago

I ran into the same problem today, was also fixed by @CacheKey. If there is only one custom deserialiser then no need for warning otherwise the need arises. I guess documentation should also be updated to show how to implement custom deserialisers and state that @CacheKey should be used