What is Type Assertion in TypeScript

In TypeScript, Type Assertions allow developers to explicitly specify the type of a variable to the TypeScript compiler.  When the compiler cannot infer the type of a variable and the developer is more sure about the type, they can use a type assertion. Type assertions are a compile-time construct that does not result in runtimeContinueContinue reading “What is Type Assertion in TypeScript”

What are Discriminated Unions Patterns in TypeScript?

Recently, I came across a pattern named Discriminated Unions Types in TypeScript. In this blog post, let us learn about that. Discriminated Unions are a pattern where each type in the union has a common property. In TypeScript, a union type allows a variable to hold one of several specified types. A straightforward example of aContinueContinue reading “What are Discriminated Unions Patterns in TypeScript?”