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

compilerOptions.plugins of tsconfig.json ignored? #1826

Closed
aradalvand opened this issue Jan 10, 2023 · 2 comments
Closed

compilerOptions.plugins of tsconfig.json ignored? #1826

aradalvand opened this issue Jan 10, 2023 · 2 comments

Comments

@aradalvand
Copy link

aradalvand commented Jan 10, 2023

Describe the bug

I'm using SvelteKit and trying to use Vite's CSS Module feature, and it works pretty well; the only thing that's lacking that would make it ideal is type-safety.

For that, I tried to use "typescript-plugin-css-modules", which requires you to add a compilerOptions.plugins to your tsconfig.json file. Here's what mine looks like (it's the default tsconfig.json file in SvelteKit templates + a plugins array pointing to "typescript-plugin-css-modules"):

{
    "extends": "./.svelte-kit/tsconfig.json",
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true,
        "skipLibCheck": true,
        "sourceMap": true,
        "plugins": [{ "name": "typescript-plugin-css-modules" }]
    }
}

Now, this seems to work perfectly in .ts files, and I get the right typing:

image

In .svelte files, however, it doesn't — it seems to be ignoring tsconfig.json's plugins, and just falling back to the types declared by Vite.

image

Another possible explanation is that the Svelte language server is using VS Code's TypeScript version, as opposed to the workspace's TypeScript version — which is what "typescript-plugin-css-modules" needs (see this). The extension could provide an option to change that, like Volar does.
But I'm not familiar with the inner workings of the codebase to be able to tell. So, I'd appreciate some help. Thanks.

System Info

  • OS: Ubuntu 22.04
  • IDE: VSCode

Which package is the issue about?

svelte-language-server

@aradalvand aradalvand added the bug Something isn't working label Jan 10, 2023
@jasonlyu123 jasonlyu123 removed the bug Something isn't working label Jan 10, 2023
@aradalvand
Copy link
Author

@jasonlyu123 What is the right label for this issue? Could you provide an explanation as to why it isn't "bug"?

@jasonlyu123
Copy link
Member

I am closing as a duplicate of #905. The typescript plugin feature is only available in the tsserver but we're using a lower-level languageService API. And the plugin creation option also requires some tsserver specific APIs so we can't load the plugin by ourselves either.

We could maybe create a 3rd party interface for loading the plugin but the existing plugins still need to adopt for that to work.

@jasonlyu123 jasonlyu123 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants