Skip to content

Typescript: IDE reports TS2307: Cannot find module error for Vue components imports #1198

Closed
@wujekbogdan

Description

@wujekbogdan

Version

3.0.0-beta.9

Reproduction link

https://pastebin.com/N5A5uWGv

Steps to reproduce

  • Install Vue with vue-cli,
  • Choose Typescript support
  • Open any file that imports *.vue files

What is expected?

No errors are reported

What is actually happening?

IDE reports TS2307: Cannot find module error for Vue components imports. Imports are higlighted in red.


I've already reported this error here: vuejs/vue-class-component#219 because I thought that it is a vue-class-component issue, but it's not. It's a configuration issue.

Putting the following vue-shim.d.ts declaration file under my ./src directory solves the problem:

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

vue-components-imports-ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions