question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An import path cannot end with a '.ts' extension. Consider importing 'xx.js' instead.

See original GitHub issue
  • [ x] I have searched through existing issues
  • [ x] I have read through docs
  • [ x] I have read FAQ
  • [ x] I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: Win10
  • Vetur version:0.33.0
  • VS Code version:1.53.2
// tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "allowJs": true,
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": ["webpack-env", "jest"],
    "paths": {
      "@/*": ["src/*"]
    },
    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": ["node_modules", "public"]
}
//.eslintrc.js

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/essential',
    'eslint:recommended',
    '@vue/typescript/recommended',
    '@vue/prettier',
    '@vue/prettier/@typescript-eslint'
  ],
  parserOptions: {
    ecmaVersion: 2018
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-unused-vars': 'warn',
    '@typescript-eslint/no-non-null-assertion': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-this-alias': 'off',
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/camelcase': 'off',
    '@typescript-eslint/no-var-requires': 'off',
    'vue/require-component-is': 'off'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]
}

// webpack
  resolve: {
    alias: {
      '@': 'src',
      vue$: 'vue/dist/vue.runtime.esm.js'
    },
    extensions: [
      '.tsx',
      '.ts',
      '.mjs',
      '.js',
      '.jsx',
      '.vue',
      '.json',
      '.wasm'
    ],
}

Problem

An import path cannot end with a ‘.ts’ extension. Consider importing ‘@/utils/eventBus.js’ instead. image

It works right in v0.32.0, so i back to 0.32.0 for now.

Reproducible Case

see this git

i modify a file. in src\views\zip\index.vue

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
yoyo930021commented, Mar 3, 2021

It’s a breaking change in typescript 4.2. https://devblogs.microsoft.com/typescript/announcing-typescript-4-2/#d-ts-extensions-cannot-be-used-in-import-paths

You can change your code or use old version typescript with vetur.useWorkspaceDependencies.

1reaction
drengrcommented, Oct 5, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

An import path cannot end with a '.ts' extension ... - CSDN博客
An import path cannot end with a '.ts' extension. Consider importing '@/core/services/JwtService.js' instead. 告诉大家最快的修改方法:
Read more >
An Import Path Cannot End With '.Ts' - Nodejs And Visual Code
TS2691 : An import path cannot end with a '.ts' extension. ... When using vscode I think that it will. ... Consider importing...
Read more >
Why does typescript allow me to import dependencies it can't ...
3 Answers 3 · CommonJS modules are meant to be imported like const library = require('library') which allows to retrieve the full exports...
Read more >
FAQ | Vetur - GitHub Pages
Vetur cannot recognize my Vue component import, such as import Comp from './comp'. You need to add .vue extension when importing SFC. More...
Read more >
Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found