[Vuejs]-Vue component cannot resolve relative component imports in typescript

3👍

This is correct. The reason this occurs is that the vetur cannot find the path to the module ./Navbar. However, it can find the path to ./Navbar.vue.

You can see from the comment by a Vetur maintainer that importing components without the .vueextension is not supported.

You will also need to declare a vue-shim.d.ts that declares the typings for .vue so you don’t get explosions there, as well:

declare module "*.vue" {
  import Vue from 'vue'
  export default Vue
}

Now, mind you, this will only happen in files where the script lang="ts", outside of that you won’t see this issue as Vetur will not process any of the javascript within the script block as typescript (true for SFCs)

Leave a comment