3 ms·
There's never any trace of typescript types at runtime.
by JonChesterfield 2y ago
There's never any trace of typescript types at runtime.
- mistercow 2y agoIf you wrapped the value to give it a “brand”, the wrapper would still exist at runtime. The technique in the article avoids that.
- aidos 2y agoBy “trace” I think GP meant that the required wrapper is still there at runtime but was only in service of the type system.
- mattstir 2y agoI think what they meant is that at runtime, you don't end up with objects that look something like: { "brand": "Hash", "value": "..." } which would be the case if you used the more obvious wrapper route. Using this branding approach, the branded values are exactly the same at runtime as they would be if they weren't branded.
- recursive 2y agoWell, enums.