pzuraq / macro-decorators

Decorators for getter/setter macros!
https://pzuraq.github.io/macro-decorators/
MIT License
62 stars 10 forks source link

Errors with null or undefined Array decorators #17

Open tavosansal opened 4 years ago

tavosansal commented 4 years ago

I noticed that using decorators that have to do with arrays sort and sortBy, if the value provided to the decorator to sort is null or undefined then the decorator errors out at runtime with something similar to cannot call slice() of undefined. I am providing a guarded value now so that the decorator has an empty array as a source at least. But I wonder if the library itself should guard agains these cases? Like maybe do an array check before calling slice here? https://github.com/pzuraq/macro-decorators/blob/master/src/index.ts#L1163