Category: TypeScript
-
Interface Segregation Principle in TypeScript
The interface Segregation Principle is one of the fundamental principles of the SOLID principle. It says to keep the interface as small as possible. In the words of Uncle Bob, keep interfaces small so that classes don’t end up depending on things they don’t need. A client ( class) should not be forced to implement…
-
Make all properties optional using Partial in TypeScript
The utility type Partial<Type> makes all properties of a type optional. Using a scenario, let us try to understand Partial<T> in TypeScript. So, you have a type called Product, that is created as below: export interface Product { Id: string; Title: string; Price: number; inStock: boolean; Quantity: number; } And there is a function to update the price of a product as shown…