[DotNet] Were there ideas of having strongly typed properties? #4248
Unanswered
Danielku15
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
On .net it is quite a hassle to use the Terraform CDK properly because of the union types used in TypeScript for many properties. In the .net generation a lot of properties result in a simple
object?
which removes any type safety and is prone for users to set things correctly.So I was wondering if there were ideas and/or attempts to get a better type safety by using a fake-union type which gives a certain level of compile time safety.
I prepared a small example on how such a runtime safety could look like. It uses the implicit and explicit casting operators to make the usage more convenient:
Of course the backend/serialization parts would have to be adjusted accordingly but the benefit for developers would be huge.
Beta Was this translation helpful? Give feedback.
All reactions