Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amcsi opened this issue Jun 4, 2020 · 3 comments
Closed

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

amcsi opened this issue Jun 4, 2020 · 3 comments

Comments

@amcsi
Copy link

amcsi commented Jun 4, 2020

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)

@haoqunjiang
Copy link
Member

It is expected behavior and the linked issue has explained it well.

In the next major version, we'll stop supporting extension-less import of single file components at all (currently there's only the type checking error).

navonod added a commit to navonod/vue-splide that referenced this issue Mar 16, 2021
Please see vuejs/vue-cli#5549 (comment) - VUE-CLI no longer supports extension-less imports of SPC's (Single Page Components) - which is now breaking the vue-splide plugin :-(
@douglasg14b
Copy link

@sodatea Is this documented somewhere for reference?

@nVitius
Copy link

nVitius commented May 21, 2021

It is expected behavior and the linked issue has explained it well.

In the next major version, we'll stop supporting extension-less import of single file components at all (currently there's only the type checking error).

@sodatea Can you confirm that this change is still expected to occur?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants