New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngIf type narrowing feature does not work within "else" template #21504
Comments
|
A workaround until this is implemented is <ng-template #createdTemplate>
State {{ $any(newState).name }} created
</ng-template> |
|
I think the simplest workaround would be To tell TypeScript that it is not But I wasn't looking for a workaround, I simply wanted to warn the Angular team about this issue. |
|
It seems to generally not working with ng-templates: user?: { name: string }<ng-content *ngIf="user; then currentUser else loginButton"><ng-content>
<ng-template #currentUser>{{ user.name }}</ng-template> <!-- error -->
<ng-template #loginButton>...</ng-template> |
|
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
|
@vicb I would argue that this is a bug, not a feature -- and now that label apparently matters because it triggered the vote-bot to show up. (I think most users are going to wind up with strict templates by default sooner or later, so this is actually a pretty big deal.) |
|
hm, pretty old issue for such a bug. is there any news about this? I would appreciate not having to use |


Relative to #20967
I'm submitting a...
Current behavior
Compilation with option
fullTemplateTypeCheckthrow errorObject is possibly 'undefined'Expected behavior
No error, because the
ngIf; elsecan work as a guardMinimal reproduction of the problem with instructions
The text was updated successfully, but these errors were encountered: