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

Identifier has alreay been declared error when naming a type the same as a variable in svelte5 script #13125

Closed
zhihengGet opened this issue Sep 4, 2024 · 4 comments
Labels

Comments

@zhihengGet
Copy link

zhihengGet commented Sep 4, 2024

Describe the bug

cant have smae name as variable ...

after using @sveltejs/vite-plugin-svelte@4.0.0-next.6

src/routes/+page.svelte:4:12 Identifier 'data' has already been declared
src/routes/+page.svelte:4:12
2 |    import Counter from '$lib/Counter.svelte';
 3 |    type data = {}
 4 |    export let data;
                   ^
 5 |  </script>

Reproduction URL

<script lang="ts">
	import Counter from '$lib/Counter.svelte';
	type data = {}
	export let data;
</script>

Hello {data.name}!

Reproduction

link

Logs

-

System Info

-
@zhihengGet zhihengGet added the bug label Sep 4, 2024
@dominikg
Copy link
Member

dominikg commented Sep 4, 2024

moving to svelte repo

svelte5 repl

@dominikg dominikg transferred this issue from sveltejs/vite-plugin-svelte Sep 4, 2024
@dominikg dominikg changed the title vite-plugin-svelte unable to differ from variable name and type name Identifier has alreay been declared error when naming a type the same as a variable in svelte5 script Sep 4, 2024
@dummdidumm
Copy link
Member

dummdidumm commented Sep 4, 2024

In the meantime, either name them differently, or reenable the script preprocessor in your config (it was disabled by default for vite-plugin-svelte 4): preprocess: vitePreprocess({ script: true })

@levibassey
Copy link

reenable the script preprocessor in your config (it was disabled by default for vite-plugin-svelte 4): preprocess: vitePreprocess({ script: true })

@dummdidumm I tried this and it works, but is there a way to get rid of the red squiggly lines

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants