question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. Create a new Angular app, open the tsconfig.json and update angularCompilerOptions to
  "angularCompilerOptions": {
    "enableIvy": true
  }
  1. open app.component.html and update its content to:
<ng-container *ngTemplateOutlet="test1"></ng-container>

<ng-template #test1>
   <some-component></some-component>
</ng-template>
  1. Run ng serve and observe no build errors (<---- Issue here)
  2. open tsconfig.json and update angularCompilerOptions to:
  "angularCompilerOptions": {
    "enableIvy": false
  }
  1. Run ng serve and observe a build error
  2. Open the tsconfig.json and update angularCompilerOptions to
  "angularCompilerOptions": {
    "enableIvy": true
  }
  1. 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>
  1. 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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alxhubcommented, May 26, 2020

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.

2reactions
JoostKcommented, Mar 20, 2020

I can explain that 😃

If fullTemplateTypeCheck is disabled, any ng-template (or structural directive template) in an Angular template are not type checked for compatibility reasons (the fullTemplateTypeCheck 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 outside ng-template are always checked, regardless of fullTemplateTypeCheck.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found