79140236

Date: 2024-10-30 08:35:15
Score: 0.5
Natty:
Report link

In Angular 18.02^ you can use transform option for @Input():

class ParentComponent {
   data: Dog | Cat;
}

** parent template **
   <app-child-component [cat]="data" />
**

class ChildComponent {
   @Input({ transform: (v: Dog | Cat) => v as Cat }) cat!: Cat;
}

docs: https://angular.dev/guide/components/inputs

Reasons:
  • Whitelisted phrase (-1.5): you can use
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: TheSinOfGreed