Sometimes the compiler needs help figuring out a type. In this lesson we learn how to help out the compiler with Typescript type assertion.
So ... if type assertion no longer exists after the compilation, what's the point of it? 🙂 I guess the main purpose is to avoid the compiler error (in case we want to use different types where they don't share the same variable)?
That's the basic idea. A good example would be if you want to create a variable that needs to be modified later, maybe with an ajax call...
interface Stuff { things: string; }
let stuff: Stuff = ({} as Stuff);
const ajax = "things";
stuff.things = ajax;