-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
TS: Named export from module script not recognized #550
Comments
I'm not sure if we can solve this. The problem is that the Typescript Language Service does not know how to deal with Svelte files. There's just a minimal type definition in |
If this is going to be kept open, should it be transferred to the language-tools repo? |
Yeah, I'm currently using Another solution (not at all clean though) might be to automatically generate I've used a similar approach with a custom css module setup in one of my projects. This would get rid of the error during compile/linting/testing. I've coupled it with a typescript plugin which then tricked the editor into recognizing the css classes as exports and allowed completion/linting during development even before the |
That's an interesting solution! Would you like to share your plugin code? I did not setup a TS plugin before, but thought about setting one up for Svelte before and having kind of a blue print would certainly help. |
I'm actually using this awesome plugin by @mrmckeb https://github.com/mrmckeb/typescript-plugin-css-modules :) For the compilation step maybe it could be possible to add an option to the typescript preprocessor for svelte-preprocess to generate the declaration for every svelte component while running. If I a tool uses svelte-preprocess it would then immediately get the correct typings |
https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin Seems like angular language service use the plugin technique. We could probably learn something from their code 😂. |
I'm not sure you want to learn from my code haha, but if you have any questions I'll do my best to answer. Thanks for the shout-out @IgnusG. The only note I'll make is that Language Service plugins only run in IDEs, not during build-time. People have been asking for this change for a while, but the TypeScript team don't seem convinced that it's a good direction. |
Initially support - rename (doesn't work properly for all kinds of renames yet; need to filter out references inside generated code) - diagnostics - find references (need to filter out references inside generated code) This makes all files TSX hardcoded for now, it seems the TS server is okay with importing tsx into js sveltejs#580 sveltejs#550 sveltejs#342 sveltejs#110
There exists a TypeScript plugin now which comes packaged with the VS Code extension and which you need to enable through the settings. It also is available standalone as a npm package if you need to use it outside of VS Code. |
Describe the bug
Importing named exports from
<script context='module'>
returns an error saying:Module '"*.svelte"' has no exported member ...
The svelte component looks like this:
Typescript Config
3.24.1
4.2.1
1.0.10
4.0.2
Expected behavior
The exports should be recognized
Severity
Not severe. Just a small hindrance
The text was updated successfully, but these errors were encountered: