athena-framework / athena

An ecosystem of reusable, independent components
https://athenaframework.org
MIT License
211 stars 17 forks source link

Add `array_of` DI extension macro #348

Closed Blacksmoke16 closed 7 months ago

Blacksmoke16 commented 7 months ago

Follow up to https://github.com/athena-framework/athena/issues/332#issuecomment-1933299250, I thought about it and realized there's not much benefit in having the dedicated type macros, just to try and construct the type that you could otherwise get directly off the TypeDeclaration.

However, I did see a lot of value in the array_of macro as a means of defining an array of anonymous strictly typed objects. Before you had to do this as an array of a named tuple type, but this had some downsides. Mainly that you are unable to define defaults for the property. As such in order to make a key optional, it had to be nilable.