Vue-class-component: Type definition file disables intellisense in VS Code with Vetur

Created on 10 Nov 2017  路  6Comments  路  Source: vuejs/vue-class-component

I have downloaded the example files from this repository. I have not changed anything. I get the following issue when using Vetur and VS Code:

When including the sfc.d.ts file, intellisense for .vue files gets disabled. I don't get errors for importing non-existing files, and code changes in .vue files are not reflected in intellisense.

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

index.ts

    // import only works when INCLUDING the sfc.d.ts file
    import App from './components/app.vue'

app.vue

    <template></template>
    <script lang="ts">
        // intellisense is completely disabled unless I EXCLUDE the sfc.d.ts file!
        import Card from "./notexisting/nothing.vue"      // no error
    </script>
    <style></style>
invalid

All 6 comments

Thanks, but is adding yet another alpha plugin really a good idea? Please note that Vetur works perfectly fine when I exclude the definition file. Typescript intellisense and module imports work... webpack works... Only the one .ts file can't import a .vue file... The fact that none of the docs mention this makes me think the issue has to be on my end...

https://github.com/vuejs/vetur/issues/423#issuecomment-340321882

Please read the thread thoroughly. Vetur cannot configure TypeScript's editing behavior. You have to use a tsserver plugin.

declare module "*.vue" {

This means all assets that matches this pattern will have the declared types. So this is expected behavior.
https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations

If you want to change this behavior, you need to use extra ts plugin.

Closing since there are nothing we can do for this behavior in vue-class-component side.

Thanks for looking into this. This essentially means that Vue is not yet ready to be used with typescript single file components. I'm very surprised since the Vue website doesn't mention this, and even seems to encourage SFC's.

@kokodoko Please Use webstorm

Was this page helpful?
0 / 5 - 0 ratings