Angular can typecheck your templates in AOT and throw errors at compilation phase.
Unfortunately this doesn't seem to work when using as
keyword, for example in ngIf
:
*ngIf="typedVariable as newVariable"
or in more common case, *ngIf="typedObservable | async as newVariable"
.
newVariable
in both cases is not type safe, i.e. I can do {{ newVariable.anyInvalidPropertyNameNotPresentInTypedVariable }}
without any errors or warnings (which is not the case with {{ typedVariable.anyInvalidPropertyNameNotPresentInTypedVariable }}
).
Is there any way to achieve type safety, especially in async as
case?