undefined Output should show error in the parent template
See original GitHub issueWhich @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:
- Created 2 years ago
- Reactions:22
- Comments:9 (7 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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 nativeEvent
type.Just an idea:
Like attributes (
[attr.foo]
) vs input properties ([foo]
) , we could(event.click)
to DOM events(click)
to ‘click’ output property only (in future, but only deprecate DOM event usage 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.