Skip to content

Can't use interfaces #220

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

Closed
benkeil opened this issue Aug 13, 2020 · 2 comments
Closed

Can't use interfaces #220

benkeil opened this issue Aug 13, 2020 · 2 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@benkeil
Copy link

benkeil commented Aug 13, 2020

Describe the bug
Can't use interfaces in .svelte files.

To Reproduce
Create a file with a TypeScript interface and import it in a .svelte file.

Expected behavior
Should work

Stacktraces

[!] Error: 'default' is not exported by src/MyInterface.ts, imported by src/App.svelte
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module

Information about your project:

  • Your browser and the version: newest Safari

  • Your operating system: macOS 10.15

  • svelte-preprocess latest

  • Whether your project uses Webpack or Rollup: Rollup

@kaisermann kaisermann self-assigned this Aug 13, 2020
@kaisermann kaisermann added the invalid This doesn't seem right label Aug 13, 2020
@kaisermann
Copy link
Member

Hey @benkeil 👋

You need to use the type import modifier: import type { ... } from ....

Duplicate of #214 and #206

@benkeil
Copy link
Author

benkeil commented Aug 13, 2020

Still don't get it to run.

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
../../adapters/src/FooImpl.ts (1:12)
1: import type Foo from '@project/core/src/Foo';
               ^
2:
3: export default class FooImpl implements Foo {
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

App.svelte

<script lang="ts">
  import FooImpl from "@project/adapters/src/FooImpl";
  import type Foo from '@project/core/src/Foo';
  const foo: Foo = new FooImpl();
  export let name: string;
</script>

<main>
  <h1>Hello { name } and { foo.getFooBar() }!</h1>
</main>

<style lang="scss">
  @import "./app";
</style>

I added an example project at https://github.com/benkeil/svelte-ts-demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants