- TypeScript
- Decorators
- Type Inference
- Metaprogramming
I want to move some boilerplate code to decorators. The background FW loads and saves at certain times. Currently this is quite custom -- but the actual requirements are not that custom. I want to make a more standardized way for this.
I'm not sure yet if it's the best -- or even significantly better than the current approach. However, I think that having a standardized way might help avoiding some of the issues we've encountered recently. As with FW development generally: it might help developers to be able to create better code.
So it enforces a few constraints, e.g. having to use explicit types for saved objects, controlled way of handling data, etc. But good constraints, I think.
We've got pretty good type constraints.
The config of the Store6
decorator is well-typed, it should help developers when something doesn't add up.
It mostly follows the actual standards we use. Missing features:
- Load raw data without transforming first
- Support lifecycle hooks
I don't like that the decorator template types are to be declared explicitly.
But I couldn't make it work implicitly yet.
Also, the error messages are not always helpful.
If the type of the decorator and the actual member are not in sync, then I enforce a never
to the target type.
The user will see that something is wrong, but it won't be that helpful.
Maybe.