Branded types for TypeScript - Carlos Menezes
Contents
Introduction
Issue
Solution
Introduction
Branded types in TypeScript enable the creation of new types by affixing a type tag to an existing underlying type. This tag, commonly referred to as the "brand", distinguishes values of the branded type from others sharing the same underlying type. Acting as a compile-time validator, the brand ensures that values are utilized correctly within their intended contexts.Issue
Imagine a scenario where a function generates a hash from a string input. ...
Read more at carlos-menezes.com