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.
It works right in v0.32.0, so i back to 0.32.0 for now.
Reproducible Case
i modify a file. in src\views\zip\index.vue
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
.Yes, you’re right. Sorry for bothering you.