Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Flavor types #1001

Open
crummy opened this issue Jul 24, 2023 · 0 comments
Open

Generate Flavor types #1001

crummy opened this issue Jul 24, 2023 · 0 comments

Comments

@crummy
Copy link

crummy commented Jul 24, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant