-
Notifications
You must be signed in to change notification settings - Fork 136
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
Brand string types #185
Comments
@abuiles I think this is a great task to consider, since the sooner we implement and commit to the branded types, the sooner devs can use them in their apps. |
I gave a though how to proceed with this. IMO this is the best, least-breaking way:
Some cons:
|
@Akuukis sounds like a good plan! Do you want to have a stab at it? Thanks! |
Ok, did steps 1 & 2 here #214 and stellar/js-stellar-sdk#384 for Secret, AccountId and PublicKey. For step 3 please see what makes common sense for you and what's not, so I can have a checklist to describe. |
Problem
Many data structures are represented as strings, and types don't help much because string matches string. E.g.
Describe the solution you'd like
I propose to brand all those strings. That way TypeScript compiler can pick up all the problems. Something like this:
This even has potential to track the narrowed types through serialization if needed.
Describe alternatives you've considered
Less strict alternative is to use simple aliases and excessive comments.
The text was updated successfully, but these errors were encountered: