Skip to content
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

Auto Importing a .ts, .vue file prints the file with .js extension #1763

Closed
devhus opened this issue Aug 25, 2022 · 3 comments
Closed

Auto Importing a .ts, .vue file prints the file with .js extension #1763

devhus opened this issue Aug 25, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@devhus
Copy link

devhus commented Aug 25, 2022

Hello there,
I am on a Typescript project and Valor keeps importing .ts files with ".js" ext instead. Later on cases issues with Vite builds where i need to remove/replace ".js" in all imports lines manually, and i have no idea what is causing that.

image

volar version: 0.39.5

Vite configs

import { fileURLToPath, URL } from 'url';

import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  build: {
    rollupOptions: {
      plugins: [
        visualizer()
      ]
    }
  }
})

ts.config

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "lib": ["esnext", "dom"],
    "target": "esnext",
    "module": "esnext",    
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "composite": true,
    "allowJs": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "noImplicitAny":false,
    "importsNotUsedAsValues": "preserve",
    "preserveValueImports": false
  }
}

.eslintrc.cjs

/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
  "root": true,
  "extends": [
    "plugin:vue/vue3-essential",
    "eslint:recommended",
    "@vue/eslint-config-typescript/recommended"
  ],
  "env": {
    "vue/setup-compiler-macros": true
  }
}
@devhus devhus changed the title Auto Importing a ts file prints the file with .js extension Auto Importing a .ts, .vue file prints the file with .js extension Aug 25, 2022
@johnsoncodehk
Copy link
Member

You can config "javascript/typescript.preferences.importModuleSpecifierEnding": "minimal" in VSCode to avoid this problem for now.

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Aug 27, 2022
@sheremet-va
Copy link

You can config "javascript/typescript.preferences.importModuleSpecifierEnding": "minimal" in VSCode to avoid this problem for now.

@johnsoncodehk this option is not supported in Take Over mode.

@johnsoncodehk
Copy link
Member

Fixed by f786efa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants