I'm currently running into an issue/question about optional chaining in Angular. I'm running Angular 20, with "strictTemplates": true enabled as angularCompilerOptions and "strict": true, as compilerOptions.
@if(component().metadata?.title){
<span>{{ component().metadata?.title }}</span>
}
In the above example, I have a signal input, which has an interface where metadata is an optional field. If I would delete the ? after metadata inside the span element, it would throw an error: Object is possibly 'undefined'. That feels a bit weird, since the @if statement is around it.
I would expect the below code to run fine, but it isn't.
@if(component().metadata?.title){
<span>{{ component().metadata.title }}</span>
}
Is this the expected behavior? Or can this be resolved?