Skip to content

Cannot import Vue file without .vue extension (typescript) #5549

@amcsi

Description

@amcsi

Version

4.4.1

Reproduction link

https://github.com/amcsi/vue-cli-ts-problem-demo

Environment info

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 10.17.0 - ~/.nvm/versions/node/v10.17.0/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v10.17.0/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v10.17.0/bin/npm
  Browsers:
    Chrome: 83.0.4103.61
    Firefox: 76.0.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.4.1 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.4.1 
    @vue/cli-plugin-babel: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-e2e-cypress: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-eslint: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-router: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-typescript: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-unit-jest: ~4.4.0 => 4.4.1 
    @vue/cli-plugin-vuex: ~4.4.0 => 4.4.1 
    @vue/cli-service: ~4.4.0 => 4.4.1 
    @vue/cli-shared-utils:  4.4.1 
    @vue/component-compiler-utils:  3.1.2 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/eslint-config-typescript: ^5.0.2 => 5.0.2 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/test-utils: ^1.0.3 => 1.0.3 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^6.2.2 => 6.2.2 
    jest-serializer-vue:  2.0.2 
    typescript: ~3.9.3 => 3.9.3 
    vue: ^2.6.11 => 2.6.11 
    vue-eslint-parser:  7.1.0 
    vue-hot-reload-api:  2.3.4 
    vue-jest:  3.0.5 
    vue-loader:  15.9.2 
    vue-router: ^3.2.0 => 3.3.2 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.4.0 => 3.4.0 
  npmGlobalPackages:
    @vue/cli: 4.4.1

Steps to reproduce

Clone the repo.
Run yarn install.
Run yarn run serve.

What is expected?

It compiles fine without errors.

What is actually happening?

See that there's a TS error: Cannot find module '../views/Home' or its corresponding type declarations.


All I did was remove the .vue extension in the index.tsx's import statement that was there out of the box from vue-cli

import Home from "../views/Home.vue";
to
import Home from "../views/Home";

Screenshot:
Screenshot from 2020-06-04 11-55-19

Possible related issue:
vuejs/vue#5298 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions