Get the latest tech news

TypeScript: Branded Types


How to brand TypeScript types for norminal typing

Much like in the TypeScript mapped types article, the key lies in creating a field with the name of a symbol to act as our id. TypeScript won't let us pass an instance of B to the function accepting A because it's missing the brand field - brilliant! For completeness, here's the same kind of thing to remove the brand and go back to plain ol' TypeScript types:

Get the Android app

Or read this on Hacker News

Read more on:

Photo of branding

branding

Related news:

News photo

Google axes 'Fitbit by Google' for new, more on-point branding.

News photo

Comcast agrees to kill 10G branding after advertising watchdogs said it was misleading

News photo

HMD Global's upcoming smartphone might ditch the Nokia branding