-
Notifications
You must be signed in to change notification settings - Fork 21
svelte plugin: <Component> is not defined #4
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
Comments
I think the Recursion has occurred :) |
@pyoner I think we should somehow convince Typescript compiler don't import svelte file at all. Just leave it as is. |
@PaulMaly check my transpile.js file https://github.com/pyoner/svelte-ts-preprocess/blob/import-svelte/tests/transpile.js But I added some code (https://github.com/pyoner/svelte-ts-preprocess/blob/import-svelte/tests/transpile.js#L5), because Here output: { outputText: 'import Form from \'./Form.svelte\';\nForm;\nimport y from \'./module.ts\';\nlet x = y;\nlet z = \'\';\n',
diagnostics: [],
sourceMapText: undefined } I think something is wrong with compiler options in your code |
|
I think we can ignore this error |
The problem here is that you import Form component, but don't use it in the script, so TS compiler simply removes it. There were few issues created in TypeScript repo to make it possible to force import of "unused" modules, but most of them were closed because this is intended behavior. Quick and dirty fix: <script lang="ts">
import Form from "./Form.svelte";
export let name;
console.log(Form)
</script> |
@pyoner Can't check your example because of 404 page. Can you describe your fix here or ping me in messager to discuss it? |
@PaulMaly hi, |
@pyoner Wow, you did a lot of work as I can see! Much more than I do initially. How about to add you to collaborators of this repo? |
@PaulMaly I agree :) |
PR #6 |
Hi! Thanks for the project. Library already preserves all `.svelte` imports. This PR change behaviour to preserve _all_ imports, because imported variables can be not only svelte components but also values which svelte template actually uses. Example: ``` <script lang="ts"> import { writable } from "svelte/store"; import { count } from "./stores"; import Counter from "./Counter.svelte"; export let name: number; export let age: number; </script> <h1>Hello {name} ({age})!</h1> <p> <Counter /> <Counter value={1}>Counter 1</Counter> <Counter value={$count} step={3}>Counter 2</Counter> </p> ``` Without the fix compiler throws: ``` (!) svelte plugin: 'count' is not defined src/App.svelte <Counter /> <Counter value={1}>Counter 1</Counter> <Counter value={$count} step={3}>Counter 2</Counter> ^ </p> ``` Relates to: - PaulMaly#4 - microsoft/TypeScript#9191
I have 2 files:
App.svelte
Form.svelte
And got an error:
but if I remove an attribute
lang="ts"
from theApp.svelte
file it worksThe text was updated successfully, but these errors were encountered: