TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
A Type-Safer Alternative to Type Guards in TypeScript
TypeScript allows programmers to define type guards so that programmers have more control over the dynamic nature of the typing of JavaScript. Since type guards are completely defined by the programmer, they also evade type checking from the TypeScript compiler: Type checking won’t catch any error if the type guard doesn’t correctly determine the type. This can be caused by typos, updating the type without updating the type guard, etc. For example, consider the following interface and its well-written type guard: ...