This is the repo for a talk I gave at Bloomberg in November 2019. You can step though the talk here
Consider the code in bug.ts
Can you see the problem?
The type alias to string means UserName and ErrorCode and string are all interchangable.
How would we do this in java?
Consider the code in classes.java
We can do a similar thing in C++ classes.cpp and C# classes.cs
What if we try it in TypeScript? classes.ts
No Error!
I can use Symbol and type intersections.
What are Type Intersections? type_intersection.ts
What are Symbols? symbol_use.ts
Using these techniques we have symbol.ts
We can make it simpler.
As you can see this is almost identical to our original code but is type safe.