TS: Named export from module script not recognized
See original GitHub issueDescribe the bug
Importing named exports from <script context='module'>
returns an error saying:
Module ‘“*.svelte”’ has no exported member …
The image is from a test file that imports both the component and the helper method
The svelte component looks like this:
<script context="module" lang="ts">
export const reverseValue = (min: number, max: number) => (
scale: number,
): number => max - scale + min;
</script>
...
Typescript Config
{ "extends": "@tsconfig/svelte/tsconfig.json", "compilerOptions": { "baseUrl": ".", "paths": {"*": ["*", "typings/*"]}, "noImplicitAny": true, "emitDecoratorMetadata": true, "skipLibCheck": true, "experimentalDecorators": true, "esModuleInterop": true, "noImplicitReturns": true, "noUnusedParameters": true, "strictFunctionTypes": true, "strictNullChecks": true, "types": ["jest", "chrome", "node"], "allowJs": true, "isolatedModules": false, "target": "ESNext", "allowSyntheticDefaultImports": true }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/.svelte", "typings/*.d.ts", "test/*.ts"], "exclude": ["node_modules"] }
- Svelte:
3.24.1
- Svelte Preprocess:
4.2.1
- Svelte TS Config:
1.0.10
- Typescript:
4.0.2
Expected behavior The exports should be recognized
Severity Not severe. Just a small hindrance
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:8 (5 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 😂.