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.

undefined Output should show error in the parent template

See original GitHub issue

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

core

Description

I believe I have all the template strict checks enabled, and I was expecting to have a template error at my parent component telling me that my child component does not have certain output if there is a typo in its name.

@Component({
  selector: 'app-child',
  templateUrl: './child.component.html'
})
export class ChildComponent {
  @Output() outputFromChild = new EventEmitter<string>();
}
<app-child (outputFromChildWithATypo)="handleOutputAtParent($event)"></app-child>

Proposed solution

The compiler should warn about a non-existing output in the component element.

Alternatives considered

Please let me know if this error check already exists, I may just be missing enabling it. I tried googling for it but could not find anything relevant.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:22
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
JoostKcommented, Sep 27, 2021

There is indeed a gap in type-checking here. The misnamed output does have a valid target though: the app-child DOM element that is rendered. We don’t currently check output against the DOM schema, so any unknown output is not reported.

You can partially workaround using "strictDomEventTypes": true, as that would have made $event of the DOM’s native Event type.

0reactions
ippeiukaicommented, Oct 17, 2022

Just an idea:

Like attributes ([attr.foo]) vs input properties ([foo]) , we could

  • bind (event.click) to DOM events
  • bind (click) to ‘click’ output property only (in future, but only deprecate DOM event usage for a while)
  • add an angularCompilerOption to strictly detect unknown output property (opt-in for existing projects for a while)

Thoughts behind: Checking against DOM schema would be impractical given that custom DOM events of any arbitrary name can be dispatched by any library. Especially interoperability with WebComponents may be of concern as CustomEvents are one of their primary interface. Having separate syntax (pseudo binding) for DOM event names would be much more beneficial.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Output is not defined` when passing value outside a directive ...
I have an root-app component which is defined like this in the template. ... is a list and on selection of one of...
Read more >
lightning web components - Push fail for "force:source:push
Error force-app\main\default\lwc\myFirstWebComponent\myFirstWebComponent.js bad result: TypeError: Cannot read property 'parent' of undefined at ...
Read more >
Template Designer Documentation - Jinja
Due to how scopes work in Jinja, a macro in a child template does not override a macro in a parent template. The...
Read more >
Built-in Helpers - Handlebars
If its argument returns false , undefined , null , "" , 0 , or [] , Handlebars will not render the block....
Read more >
NG0100: Expression has changed after it was checked - Angular
This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like ngAfterViewInit or ngOnChanges .
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