Skip to content

Missing Typings for Event Hooks in HTML Template #40

New issue

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
5 tasks done
JordanW9232 opened this issue Apr 1, 2023 · 6 comments · Fixed by #41
Closed
5 tasks done

Missing Typings for Event Hooks in HTML Template #40

JordanW9232 opened this issue Apr 1, 2023 · 6 comments · Fixed by #41
Labels

Comments

@JordanW9232
Copy link

Describe the bug

None of the event hooks have proper typings when used in a HTML template. When using an event hook in html like (onChange)="onMarkdownChange($event)" it is not recognized and will show the following message:

Event onChange is not emitted by any applicable directives nor by angular-markdown-editor element

Although this message is shown, everything still compiles successfully and my function still works as expected, so this is only an issue with typings.

Reproduction

Use an event hook like (onChange)="onMarkdownChange($event)"

Environment Info

Angular 15.2.2
Angular-Markdown-Editor 3.0.2
Typescript 4.9.5
Windows 11

Validations

@ghiscoding
Copy link
Owner

Custom Events are always showing errors in recent Angular versions within HTML templates and I never found how to fix this kind of issue (I'm not sure it's even possible because of Angular-Language-Service). For example, similar a similar issue was opened in another lib of mine (Angular-Slickgrid), see this discussion, There are 2 things you can do to, you can either cast to $any($event) in the HTML template or change your function argument as CustomEvent and then cast the argument to the necessary interface, again see this discussion for more info. It would be great if Angular could ever provide instructions on how to fix it

I'm going to close this issue as "not doable", unless you know how to fix this, if it's even possible

@JordanW9232
Copy link
Author

I think I may actually see the fix. I'll try making a new fork and see what I can come with. If I figure something out I could create a pull request.

@JordanW9232
Copy link
Author

@ghiscoding I managed to figure this out and made a pull request for this here: #41.

@JordanW9232
Copy link
Author

I read that discussion again that you sent and I should mention that I use Webstorm, not VS Code. So the IDE may just behave differently than that Angular Language Service extension that you mentioned.

@ghiscoding
Copy link
Owner

yeah I just saw your PR and merged it, I didn't know it was that simple. I don't think I can apply this type of change to my other lib since it's close to 100 different events. Thanks

@ghiscoding
Copy link
Owner

closed by #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants