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

Exports other than default are not supported in typescript #648

Closed
cortopy opened this issue Nov 2, 2020 · 1 comment
Closed

Exports other than default are not supported in typescript #648

cortopy opened this issue Nov 2, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@cortopy
Copy link

cortopy commented Nov 2, 2020

Describe the bug
As per the docs when exporting something from a <script context="module">that something is available to import in javascript files.

<script context="module">
	let totalComponents = 0;

	// this allows an importer to do e.g.
	// `import Example, { alertTotal } from './Example.svelte'`
	export function alertTotal() {
		alert(totalComponents);
	}
</script>

<script>
	totalComponents += 1;
	console.log(`total number of times this component has been created: ${totalComponents}`);
</script>

To Reproduce
However, when trying a similar example to the docs in typescript I get a similar error to this:

Module '"*.svelte"' has no exported member 'alertTotal'. Did you mean to use 'import alertTotal from "*.svelte"' instead?

Expected behavior
It's possible to import types, variables, functions, etc. from any module context in a component

Ideally both import and import type should be supported

System (please complete the following information):

  • OS: Linux
  • IDE: VSCode
  • Plugin/Package: Svelte for VS Code
@cortopy cortopy added the bug Something isn't working label Nov 2, 2020
@dummdidumm
Copy link
Member

Duplicate of #550

@dummdidumm dummdidumm marked this as a duplicate of #550 Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants