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

When tsconfig.json configures "@/*": ["src/*"] and vite.config.ts configures alias “@/”, the generated type path is incorrect. #290

Closed
3 tasks done
SKT1yang opened this issue Dec 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SKT1yang
Copy link

Describe the bug

I use "@/" as the path alias, and when packaging, the JS file in the product is normal. However, there is a missing "/" in the alias of the ".d.ts" file. For example, when I use "@/components/HelloWorld. vue", it should be converted to "./components/HelloWorld. vue", but in reality, it is converted to ". components/HelloWorld. vue"
image
image

Reproduction

https://stackblitz.com/edit/vitejs-vite-ctrqsy?file=tsconfig.json,vite.config.ts,src%2Findex.ts

Steps to reproduce

  1. npm run build
  2. look file "dist/index.d.ts"

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^4.5.2 => 4.5.2 
    vite: ^5.0.8 => 5.0.8 
    vite-plugin-dts: ^3.6.4 => 3.6.4

Validations

@qmhc qmhc added the bug Something isn't working label Dec 25, 2023
@qmhc qmhc closed this as completed in 213aa39 Dec 25, 2023
@sconix
Copy link

sconix commented Dec 30, 2023

@qmhc With this change configurations like:
"paths": { "#*": [ "./src/*" ] }

wont work anymore, not fully sure if they worked before this change did not yet have time to test with older versions. Just thought to let you already know that this fix is not perfect, will try to find time to make a new reproduction and file a new bug later.

Did quick test with the reproduction in this issue with updated dts plugin to 3.7.0 and modified it to according above setup and imports to be #components* and the output was .components/* not ./components/* as it should be.

https://stackblitz.com/edit/vitejs-vite-prdv4h?file=package.json

In our project with the #* configuration the plugin fails to completely replace the paths and they remain as #components/* in the output file. Have not yet figured out what is the difference with our project and the above reproduction, could be that we have multi project repo both vite and typescript config files are in subdirectory or its something else, will try to replicate this later and file a new bug as soon as I find time.

Our current setup uses vue-tsc + tsc-alias and that combination replaces the paths correctly, but would love to change to using this plugin.

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