Skip to content
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

missing type definitions for some class members #26

Open
trusktr opened this issue Aug 3, 2024 · 1 comment
Open

missing type definitions for some class members #26

trusktr opened this issue Aug 3, 2024 · 1 comment

Comments

@trusktr
Copy link

trusktr commented Aug 3, 2024

Looks like the type defs might need an update (willing to help if I can circle back time willing). F.e. this.contexts is available, but this.getContext() is not:

Screenshot 2024-08-03 at 1 34 58 PM Screenshot 2024-08-03 at 1 35 04 PM
@trusktr
Copy link
Author

trusktr commented Aug 3, 2024

Ah, its because the mixin uses ConsumerElement to cast the return type, which misses out on any type in the mixin class definition.

type ConsumerElement = CustomElement & {
contexts?: Record<PropertyKey, (data: any) => void>;
};

This can be fixed by allowing the return value to be the actual type returned. Instead of returning the ConsumerElement definition, it can be merged into the base Class type, then everything in the mixin class will propagate through the return value including ConsumerElement.

Alternatively, we can write duplicate types in the ConsumerElement type, but it can be error prone if the mixin class is changed but ConsumerElement isn't.

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

No branches or pull requests

1 participant