Не могу понять, почему простой *ngIf="false"
вызовет error TS2532: Object is possibly 'undefined'.
.
tsconfig. json
"compilerOptions": {
...
"strict": true,
app.component. ts
export class AppComponent {
user? : User;
}
interface User {
name: string;
}
app.component. html
<div *ngIf="user">
<div>{{user.name}}</div> <!-- OK -->
<div *ngIf="true">{{user.name}}</div> <!-- OK -->
<div *ngIf="false">{{user.name}}</div> <!-- error TS2532: Object is possibly 'undefined'. -->
</div>
Полный Angular проект: https://gitlab.com/zchlian/angular-test-strict/