Simplify Expose decorator
yfernandes opened this issue · comments
Currently to expose a property under a different name we have to use
@Expose({ name: 'id' })
Can we make it so we can simply pass a string? e.g. @Expose('id')
The exposed needs to receive which type of option, there are a few different options.
If you can think of a way to do this, please let me know.
The code:
lang/src/serialization/decorators.ts
Lines 67 to 71 in c350927
The interface:
lang/src/serialization/interfaces.ts
Lines 78 to 85 in c350927
While I don't recall the use case I suggested this alternative method, I do remember the number of instances that were used with only the name property were much greater than the instances that had multiple properties set.
So the proposed implementation would be to accept as an options type an IExposeOptions object or a string. If the object were passed the implementation would be the same, if a string was passed, however, we could assume that the string's value referred to the name property
The issue was resolved in the latest version of the package. I will close the issue.