Access parent data in alpine data function in typescript #4486
Unanswered
believelody
asked this question in
1. Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, let's take this case:
With typescript, if I want to define the alpine data function childData, alpinejs provides a generic type AlpineComponent where T is the returned object type.
I want typescript to be aware of parent's properties of childData in the scope of the function !
For instance, doing things like this:
The console.log will print the parentValue's value but when writing this line, this property will not be displayed in the available properties of "this". So it will be underlined in red color.
How can I make it work ? If parentValue is part of T, it has to be in the returned object, which isn't what I really want. Or maybe it's the only way ?
Thanks for your time
Beta Was this translation helpful? Give feedback.
All reactions