Skip to content

"Import of non-existent export" warnings when importing types #214

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
pchynoweth opened this issue Aug 8, 2020 · 1 comment
Closed

"Import of non-existent export" warnings when importing types #214

pchynoweth opened this issue Aug 8, 2020 · 1 comment
Assignees
Labels
invalid This doesn't seem right

Comments

@pchynoweth
Copy link

Describe the bug
I'm not sure if this issue belongs here or in sveltejs/rollup-plugin-svelte. I get these warnings if I try to import types from another file:

src/main.ts → public/build/bundle.js...
(!) Import of non-existent export
src/App.svelte
1: <script lang="ts">
                     ^
2:   import { TestType } from './types';
3:   export let name: string;

The arrow is in the wrong place but that's a different issue. I assume this is happening because it's being treated as a javascript import.

Logs
Please include browser console and server logs around the time this bug occurred.

To Reproduce

  1. Clone the standard template and run the typescript setup script
npx degit sveltejs/template svelte-demo
cd svelte-demo
node scripts/setupTypeScript.js
  1. Add a types file src/types.ts
export interface TestType {
  foo: string;
};
  1. import the type in src/App.svelte.
<script lang="ts">
	import { TestType } from './types';
	export let name: string;
</script>
...

Expected behavior
No warnings.

Information about your project:

  • Your browser and the version: N/A (issue occurs during build)

  • Your operating system: Arch Linux

  • svelte-preprocess version 4.0.10

  • Rollup

package.json
{
  "name": "svelte-app",
  "version": "1.0.0",
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "start": "sirv public",
    "validate": "svelte-check"
  },
  "devDependencies": {
    "@rollup/plugin-commonjs": "^12.0.0",
    "@rollup/plugin-node-resolve": "^8.0.0",
    "rollup": "^2.3.4",
    "rollup-plugin-livereload": "^1.0.0",
    "rollup-plugin-svelte": "^5.0.3",
    "rollup-plugin-terser": "^5.1.2",
    "svelte": "^3.0.0",
    "svelte-check": "^1.0.0",
    "svelte-preprocess": "^4.0.0",
    "@rollup/plugin-typescript": "^4.0.0",
    "typescript": "^3.9.3",
    "tslib": "^2.0.0",
    "@tsconfig/svelte": "^1.0.0"
  },
  "dependencies": {
    "sirv-cli": "^1.0.0"
  }
}
@kaisermann
Copy link
Member

Hey @pchynoweth, see the TypeScrpt limitations section in the preprocessing doc. To import a type, you should use the type modifier: import type { ... } from ....

@kaisermann kaisermann self-assigned this Aug 12, 2020
@kaisermann kaisermann added invalid This doesn't seem right wontfix This will not be worked on and removed wontfix This will not be worked on labels Aug 12, 2020
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