10000 Document NG0303 diagnostic when an unknown binding is present in a template · Issue #59488 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Document NG0303 diagnostic when an unknown binding is present in a template #59488

New issue
8000

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

Closed
bougwal opened this issue Jan 12, 2025 · 4 comments
Closed
Labels
area: docs Related to the documentation
Milestone

Comments

@bougwal
Copy link
Contributor
bougwal commented Jan 12, 2025

Which @angular/* package(s) are relevant/related to the feature request?

compiler

Description

Hi !

Doing large scale 'legacy' migration through SAC / CF I came over this potential optimization that might help us improve the DX slightly. Currently if a component template has NgTemplateOutlet while the respective component.imports array is missing the import of the directive, the app compiles successfully and the app might have a leaking issue that might only be caught during QA testing at runtime (supposing the respective existing component does not have properly test). I would rather expect the app to compile-time fail as it does when the aforementioned template is using something like NgClass while the respective import is missing, as this will yield NG8002 in case of missing NgClass import.


import { NgClass } from '@angular/common';
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [NgClass],
  template: `
    <!--Remove the import of NgTemplateOutlet and the compilation will succeed-->
    <ng-container *ngTemplateOutlet="ref"/>
    <ng-template #ref> <h1>can you make me fail during app compilation with NG0303 as I am compiling successfully ?</h1> </ng-template>

  <!--Remove the import of NgClass and the compilation will fail-->
  <h1 [ngClass]="show ? 'blue' : 'default'">Missing NgClass will yield NG8002 </h1>
  `,
  styles: [`
    .blue {
      color: blue; 
    }
    .default {
      color: black;
    }
  `]
})
export class AppComponent {
  title = 'repro';
  show = true; 
}

Repo: https://github.com/bougwal/NG0303

Proposed solution

I am thus, asking for:

  • The potential improvement of making NG0303 compile time failure if there are no blockers/concerns.
  • The addition of NG0303 to the error encyclopaedia, as I don't see it logged on ADEV neither under runtime nor under compile time: https://angular.dev/errors. Is there a reason to exclude it?

Let me know if I am missing smth I have to add / I look forward to the input / more context on this !

Many thanks guys !

Alternatives considered

n/a

@JoostK
Copy link
Member
JoostK commented Jan 12, 2025

Thanks for the suggestion, this is a duplicate of #37322.

The addition of NG0303 to the error encyclopaedia, as I don't see it logged on ADEV neither under runtime nor under compile time: https://angular.dev/errors. Is there a reason to exclude it?

No particular reason, it's just that this error hasn't had a page written for it.

@JoostK JoostK changed the title Enhance compile-time failure accounting for NG0303 (to detect missing NgTemplateOutlet import) as it is the case for NgClass with NG8002 Document NG0303 diagnostic when an unknown binding is present in a template Jan 12, 2025
@JoostK JoostK added the area: docs Related to the documentation label Jan 12, 2025
@ngbot ngbot bot added this to the needsTriage milestone Jan 12, 2025
@JeanMeche
Copy link
Member

Fwiw, #59443 is looking good to address this issue.

@pkozlowski-opensource
Copy link
Member

Going to close it as a duplicate of #37322 - especially since we've got a PR with a fix.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: docs Related to the documentation
Projects
None yet
Development

No branches or pull requests

4 participants
0