Ivy is not complaining about unknown element inside ng-template
See original GitHub issue🐞 bug report
Description
Ivy does not complain about an unknown element when this element is placed inside ng-template
. When it’s outside of ng-template
it throws a build error.
The issue can only be found in runtime (no component being rendered) or with fullTemplateTypeCheck: true
.
🔬 Minimal Reproduction
- Create a new Angular app, open the
tsconfig.json
and updateangularCompilerOptions
to
"angularCompilerOptions": {
"enableIvy": true
}
- open
app.component.html
and update its content to:
<ng-container *ngTemplateOutlet="test1"></ng-container>
<ng-template #test1>
<some-component></some-component>
</ng-template>
- Run
ng serve
and observe no build errors (<---- Issue here) - open
tsconfig.json
and updateangularCompilerOptions
to:
"angularCompilerOptions": {
"enableIvy": false
}
- Run
ng serve
and observe a build error - Open the
tsconfig.json
and updateangularCompilerOptions
to
"angularCompilerOptions": {
"enableIvy": true
}
- open
app.component.html
and update its content to:
<ng-container *ngTemplateOutlet="test1"></ng-container>
<some-component></some-component>
<ng-template #test1>
<some-component></some-component>
</ng-template>
- Run
ng serve
and observe a build error
🌍 Your Environment
Angular Version: 9.0.7
Please clarify if the discrepancy in the compiler behavior between steps 3
and 5
or 8
is an intended behavior.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Angular 9's Best Hidden Feature: Strict Template Checking
Find and report more errors than ever with Angular 9's Ivy compiler, strict template checking.
Read more >Angular reactive forms, input Error: No value accessor for form ...
You have not imported the module where <ion-input> was declared ... Ivy is not complaining about unknown element inside ng-template #36171.
Read more >NgIf - Angular
A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean. When the expression evaluates to...
Read more >Type-checking templates in Angular View Engine and Ivy
Basically, a Type Check Block is a block of TypeScript code which can be inlined into source files, and when type checked by...
Read more >@angular/tsc-wrapped | Yarn - Package Manager
angular -logo. Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see the fact that Ivy doesn’t complain (without
fullTemplateTypeCheck
mode) as a bug. We should match View Engine’s behavior, and that means running the unknown element checks even in basic mode, for the full template.I can explain that 😃
If
fullTemplateTypeCheck
is disabled, anyng-template
(or structural directive template) in an Angular template are not type checked for compatibility reasons (thefullTemplateTypeCheck
was introduced as a compatibility flag). In Ivy, disabling this flag causes any templates to be skipped during the type checking phase. This however is where these unknown elements would have been detected. Elements outsideng-template
are always checked, regardless offullTemplateTypeCheck
.