sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.11k stars 1.84k forks source link

Alias paths aren't being resolved by language server #12249

Open Joonel opened 1 month ago

Joonel commented 1 month ago

Describe the bug

Not being able to go to an implementation of a function when using an alias like default $lib or a custom one; Suggestions for typing imports don't work.

image


image

Reproduction

Repo with reproduction - https://github.com/Joonel/alias-bug

Create a new empty project, no TS, no JSDoc. Add any @custom-alias for a folder in svelte.config.js, import a function on +page.svelte from the index.js in that folder, then try to go to the implementation of that function.

svelte.config.js:

  kit: {
    adapter: adapter(),
    alias: {
      "@custom-alias": "./src/custom-alias",
    },
  },

paths in ./svelte-kit/tsconfig.json are as expected:

"compilerOptions": {
"paths": {
    "@custom-alias": [
        "../src/custom-alias"
    ],
    "@custom-alias/*": [
        "../src/custom-alias/*"
    ],
    "$lib": [
        "../src/lib"
    ],
    "$lib/*": [
        "../src/lib/*"
    ]
},

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.4.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.0.6 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @sveltejs/adapter-auto: ^3.2.1 => 3.2.1
    @sveltejs/kit: ^2.5.10 => 2.5.10
    @sveltejs/vite-plugin-svelte: ^3.1.0 => 3.1.0
    svelte: ^4.2.17 => 4.2.17
    vite: ^5.2.11 => 5.2.11

Severity

serious, but I can work around it

Additional Information

No response

dummdidumm commented 1 month ago

You need to add a jsconfig.json referencing that generated tsconfig, else intellisense doesn't know what these references are. We should adjust the npm create svelte CLI to add a minimum jsconfig.json if you chose no for both JsDoc and TS.