question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS: Named export from module script not recognized

See original GitHub issue

Describe the bug Importing named exports from <script context='module'> returns an error saying:

Module ‘“*.svelte”’ has no exported member …

image

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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mrmckebcommented, Sep 20, 2020

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.

1reaction
jasonlyu123commented, Sep 19, 2020

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 😂.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found