vojtechhabarta/typescript-generator

Generate Flavor types

crummy opened this issue · 0 comments

crummy commented

I've been thinking about enforcing stronger types in our codebase. We have a lot of ids that are just numbers that we pass around, and sometimes they get swapped around (which is bad).

I read this article about "Flavor Types" as a solution to this problem in TypeScript: https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/

I'm not sure how that would look in typescript-generator - perhaps a @flavor annotation on a field that would generate an appropriate type? Or perhaps an annotation that pointed to a custom serializer?

Is it possible to do something like this now in typescript-generator?