Using the optional “+” sign together with mapped type modifiers, we can create more explicit and readable type declarations. We can also use the “-” (minus) sign to remove optional declarations from properties.
Hi, quick question, in which cases we would need to avoid modifying an interface itself and choosing modify it through a type?
Hi, Eduardo! If you can modify your interface directly then I'd recommend going for that!
Mapped type modifiers are useful if you either:
In both cases, mapped type modifiers "follow" the shape of the original interface, even if it changes/gets modified in the future, and just augment it based on the rules you specify.
there's a typo here: readonly [K in key of IPet]: IPet[K]; should be readonly [K in keyof IPet]: IPet[K];