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
vm
arg in next
callback in beforeRouteEnter
isn't typed to the component
#701
Comments
vm
arg in next
callback in beforeRouteEnter
isn't typed to the component
As a note: I'm unsure of the feasibility of this one but if someone figures out how to type it, please file a PR! |
For the time being using vue-class-component can help here. next(vm => {
const main = vm as Main;
main.customVariable = 'changed text';
}); It still feels like a hack but it works at least. |
Please see also my comment here. |
I met same problem today,and I solved problem.
there is my code.
|
Another option would be to assign the component to a variable and then use
|
You can import the module from itself: <script lang="ts" setup>
// in MyComp.vue
import type Self from './MyComp.vue'
const foo = 'bar'
defineExpose({
foo,
})
defineOptions({
beforeRouteEnter: (to, from, next) => {
next(async (vm: InstanceType<typeof Self>) => {
vm.foo // string
})
},
})
</script> @posva |
@posva Also the typing seems to be off as the type of the current component is not compatible with the signatures of |
I don't know where
|
You are sure? I though there is no |
Yes, because it has the |
Version
4.0.2
Reproduction link
https://codesandbox.io/s/competent-architecture-4ezib?file=/src/App.vue
Steps to reproduce
What is expected?
returns correct instance variables
What is actually happening?
Property 'customVariable' does not exist on type 'ComponentPublicInstance{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase >'.
The text was updated successfully, but these errors were encountered: