Skip to content

Conversation

VelizarD
Copy link
Contributor

@VelizarD VelizarD commented Sep 8, 2025

With the declaration of Component as an AnyComponent with preact-custom-element in version 4.5.0 the typescript compiler complains about not compatible types:
image

This issue is caused because register function doesn’t define generic type parameters, so TypeScript doesn’t know how to infer P and S. By doing so TypeScript is happy again:

image

Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, that's what it was. I was struggling to reproduce that in newly created apps and so I assumed what I was seeing was buggy TS inference.

Thanks!

@rschristian rschristian merged commit 73feb37 into preactjs:master Sep 8, 2025
1 check passed
@VelizarD
Copy link
Contributor Author

VelizarD commented Sep 8, 2025

I wish all my PRs would be merged so fast at work ^^ Thank you :D

@VelizarD VelizarD deleted the fix/make-register-method-generic branch September 8, 2025 22:16
@rschristian
Copy link
Member

Lmao, I think we all would

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants