Make all properties optional using Partial in TypeScript

added by DotNetKicks
4/4/2022 4:42:32 PM

235 Views

The utility type Partial makes all properties of a type optional. Using a scenario, let us try to understand Partial 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...


0 comments