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

Cannot find module './$types' for routes with a leading dot like .well-known #7659

Closed
fcrozatier opened this issue Nov 15, 2022 · 5 comments · Fixed by #7683
Closed

Cannot find module './$types' for routes with a leading dot like .well-known #7659

fcrozatier opened this issue Nov 15, 2022 · 5 comments · Fixed by #7683

Comments

@fcrozatier
Copy link
Contributor

Describe the bug

For example a route like "/.well-known/change-password" (for password managers) will generate in the editor the error:

Cannot find module './$types' or its corresponding type declarations.ts(2307)

Reproduction

repo https://github.com/fcrozatier/kit_dot_routes

Logs

No response

System Info

System:
    OS: macOS 11.7.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 15.09 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 19.0.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 107.1.45.123
    Chrome: 107.0.5304.110
    Firefox: 105.0.1
    Firefox Developer Edition: 107.0
    Safari: 16.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.87 
    @sveltejs/kit: next => 1.0.0-next.546 
    svelte: ^3.44.0 => 3.53.1 
    vite: ^3.0.4 => 3.2.3

Severity

annoyance

Additional Information

No response

@dummdidumm
Copy link
Member

dummdidumm commented Nov 15, 2022

This may be an upstream TypeScript issue. There's a related and closed issue on the TS repo about that. The solution of adding the path with the dot in front doesn't work though in combination with rootDirs it seems. As a workaround you can specify the path like this, too: import('../../(as often as needed)/.svelte-kit/types/src/routes/path/to/your/file/as/written/in/your/src/routes/folder/$types')

@Conduitry
Copy link
Member

Could [x+2e]well-known be a possible workaround now with the new path escaping thing https://kit.svelte.dev/docs/advanced-routing#encoding ?

@dummdidumm
Copy link
Member

dummdidumm commented Nov 15, 2022

yes, that indeed works (type-wise)

@Rich-Harris
Copy link
Member

The linked issue says you can work around it by explicitly adding dot-prefixed directories to the include array. We control that array since it lives in the extended config — maybe we can make this work that way?

The alternative is probably to document the [x+2e]well-known workaround, since I don't expect a resolution from TypeScript itself.

@dummdidumm
Copy link
Member

I tried that out but it doesn't seem to work in combination with rootdirs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants