question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrading to TypeScript 3.7 yields vue-router type error with composition-api

See original GitHub issue

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

vue create project-name (select all options)
npm install @vue/composition-api
npm update typescript@latest -D

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>, 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>, 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>, 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>, Data>; }’ is not assignable to type ‘RouteConfig’. Types of property ‘component’ are incompatible. Type ‘VueProxy<ComponentPropsOptions<Data>, Data>’ is not assignable to type ‘VueConstructor<Vue> | ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<…>, Record<…>> | AsyncComponentPromise<…> | AsyncComponentFactory<…> | undefined’. Type ‘ComponentOptions<Vue, { [x: string]: unknown; }, never, never, ComponentPropsOptions<Data>, ExtractPropTypes<ComponentPropsOptions<Data>, false>> & VueConstructorProxy<…>’ is missing the following properties from type ‘VueConstructor<Vue>’: extend, nextTick, set, delete, and 9 more. 22 | ]; 23 |

24 | const router = new VueRouter({ | ^ 25 | mode: “history”, 26 | base: process.env.BASE_URL, 27 | routes Version: typescript 3.7.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
LinusBorgcommented, Jan 4, 2020

typecasting the imported component also works as a workaround:

{
  path: '/users',
  component: Users as VueConstructor<Vue>
}
4reactions
s-hashimoto00commented, Dec 12, 2019

This issue looks the same as https://github.com/vuejs/composition-api/issues/185

The same problem occurred, but it was solved by defining an empty “props”.

export default createComponent({
  props: {}
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to TypeScript 3.7 yields vue-router type error with ...
Scaffold a new project with CLI (TypeScript/Babel/vue-router/etc), install @vue/composition-api then upgrade to TypeScript 3.7.2
Read more >
TypeScript with Composition API - Vue.js
This is because Vue components are compiled in isolation and the compiler currently does not crawl imported files in order to analyze the...
Read more >
[Solved]-VueJS redirect issue-Vue.js - appsloveworld
beforeRouteEnter is a in-component guard, which should be in the component itself, not in the registered route. It should not even be called,...
Read more >
Vue 3 + Vue Router 4: TypeError: Cannot read properties of ...
I am using Vue 3 + Vue Router 4 + TypeScript. And I'm trying to use router.push() but I keep getting a console...
Read more >
A demo project written in Typescript and Vue Composition API ...
BASE_URL, 21 | routes, Version: typescript 3.7.2 Time: 627ms ... is also using Vue-Router , in order to avoid the TypeCheck Error Report,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found