-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Upgrading to TypeScript 3.7 yields vue-router type error with composition-api #3019
Comments
I have the same issue. Any news? |
This issue looks the same as vuejs/composition-api#185 The same problem occurred, but it was solved by defining an empty “props”. export default createComponent({
props: {}
}) |
An alternative until this is fixed is:
This may seem hacky, but I think it's better than adding empty |
@lmiller1990 did you try the suggestion from the post above yours to add |
I did, but then I need to add an empty |
typecasting the imported component also works as a workaround: {
path: '/users',
component: Users as VueConstructor<Vue>
} |
I worked around this problem by this code. {
path: '/users',
component: () =>
import("../views/User.vue")
} |
@posva I noticed you added the |
Hey Kristin, awesome! Just to make sure: this issue is about compatibility with the Vue 2 plugin, not Vue 3. But you're welcome to contribute to both :) |
It may be that the problem is at vuejs/composition-api#185 too, ending up in no contribution here |
I believe it's fixed in |
Version
3.1.3
Reproduction link
https://github.com/aaf-ww/vue-router-typescript-bug
Steps to reproduce
Scaffold a new project with CLI (TypeScript/Babel/vue-router/etc), install @vue/composition-api then upgrade to TypeScript 3.7.2
What is expected?
No type errors.
What is actually happening?
ERROR in C:/Users/x/Desktop/source/vue-router-typescript-bug/src/router/index.ts(24,30):
24:30 Argument of type '{ mode: "history"; base: any; routes: ({ path: string; name: string; component: VueProxy<ComponentPropsOptions, Data>; } | { path: string; name: string; component: () => Promise<...>; })[]; }' is not assignable to parameter of type 'RouterOptions'.
Types of property 'routes' are incompatible.
Type '({ path: string; name: string; component: VueProxy<ComponentPropsOptions, Data>; } | { path: string; name: string; component: () => Promise<typeof import("C:/Users/x/Desktop/source/vue-router-typescript-bug/src/views/About.vue")>; })[]' is not assignable to type 'RouteConfig[]'.
Type '{ path: string; name: string; component: VueProxy<ComponentPropsOptions, Data>; } | { path: string; name: string; component: () => Promise<typeof import("C:/Users/x/Desktop/source/vue-router-typescript-bug/src/views/About.vue")>; }' is not assignable to type 'RouteConfig'.
Type '{ path: string; name: string; component: VueProxy<ComponentPropsOptions, Data>; }' is not assignable to type 'RouteConfig'.
Types of property 'component' are incompatible.
Type 'VueProxy<ComponentPropsOptions, Data>' is not assignable to type 'VueConstructor | ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<...>, Record<...>> | AsyncComponentPromise<...> | AsyncComponentFactory<...> | undefined'.
Type 'ComponentOptions<Vue, { [x: string]: unknown; }, never, never, ComponentPropsOptions, ExtractPropTypes<ComponentPropsOptions, false>> & VueConstructorProxy<...>' is missing the following properties from type 'VueConstructor': extend, nextTick, set, delete, and 9 more.
22 | ];
23 |
The text was updated successfully, but these errors were encountered: