How would I correctly initialize a property that has an @Input decorator without removing strict typing?
Code below is what showing this warning
@Input
foo: FormGroup;
How would I correctly initialize a property that has an @Input decorator without removing strict typing?
Code below is what showing this warning
@Input
foo: FormGroup;
There is no way to define a decorator such that Typescript will know it will perform field initialization. The only option is to add a definite assignment modifier to the field:
@Input
foo!: FormGroup;
This will disable the check for this field alone. You can read more about this assertion here
You can make the property optional, with "?".
@Input
foo?: FormGroup;
In addition, you can make the input required in the selector component
selector: 'app-name[foo]'
So that the component is selected only if it has foo input bound.