Throughout the project, there are lots of references to "string". This is great for a quick start, but leads to possible mistakes.
For example a Hash has the same type as a PrivateKey, even if they represent different concepts!
As a dev I want to use typescript types to get at least some level of safety, by introducing type aliases that cannot be converted into each other by mistake. This concept is called branded types: https://egghead.io/blog/using-branded-types-in-typescript
With this, types can also be verified more easily, e.g. PrivateKeys should always be of length X.
@tgerboui what do you think of this concept? I would love to implement it!
Throughout the project, there are lots of references to "string". This is great for a quick start, but leads to possible mistakes. For example a
Hash
has the same type as aPrivateKey
, even if they represent different concepts!As a dev I want to use typescript types to get at least some level of safety, by introducing type aliases that cannot be converted into each other by mistake. This concept is called branded types: https://egghead.io/blog/using-branded-types-in-typescript
With this, types can also be verified more easily, e.g.
PrivateKey
s should always be of length X. @tgerboui what do you think of this concept? I would love to implement it!