ason icon indicating copy to clipboard operation
ason copied to clipboard

feat: add decorator for class to be serializable and fix types file

Open willemneal opened this issue 3 years ago • 2 comments

Now you must add @ason to a class for the transform to take place. Library files are an exception. Also added Ason class to index.d.ts.

willemneal avatar May 07 '21 17:05 willemneal

I was trying to make ASON accessible with minimal steps for the end user. If they had to explicitly annotate a class, it might be cumbersome.

Another example might be a library that wants to support ason. Currently the only requirement might be adding manual asonSerialize methods. That method works really well for libraries like temporal who only need to store a single integer to Serialize their references.

The problem comes for developers who require the ASON default Serializer. They can add the decorator to opt into default serialization, but that requires the end user to transform their source with @ason/transform.

Two solutions:

  1. Document it and accept the downside
  2. Provide a default asconfig to extend which potentially causes trouble for end users.

I think this makes disharmony.

Why is this feature necessary?

jtenner avatar May 08 '21 13:05 jtenner

I'm also not sure why this is necessary.

JSON serializers/deserializers don't require annotations for objects to be serialized/deserialized; except for special cases such as values that should be JsonIgnored. Those such cases are currently handled with the customizable __asonSerialize() and __asonDeserialize()

I'm all for some kind of annotation similar to a JsonIgnore, that will allow for some fields to be ignored without explicitly defining the custom serialize/deserialize.

RedDwarfian avatar May 08 '21 17:05 RedDwarfian