Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's never any trace of typescript types at runtime.


By “trace” I think GP meant that the required wrapper is still there at runtime but was only in service of the type system.


I 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.


If you wrapped the value to give it a “brand”, the wrapper would still exist at runtime. The technique in the article avoids that.


Well, enums.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: