Skip to content

export const breaks in svelte 5 #15357

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
KTibow opened this issue Feb 21, 2025 · 8 comments
Closed

export const breaks in svelte 5 #15357

KTibow opened this issue Feb 21, 2025 · 8 comments

Comments

@KTibow
Copy link

KTibow commented Feb 21, 2025

Describe the bug

export const no longer allows you to export a fixed value once you migrate to svelte 5

Reproduction

svelte 4 (observe that it uses svelte 4 syntax, and a 2 shows up, exported from Thing): https://svelte.dev/playground/1c7f6e4cd62c4788866295f2ee325706?version=5.20.2
svelte 5 (observe that it uses svelte 5 syntax, and since v is undefined, nothing shows up): https://svelte.dev/playground/000e19b8335847938feffe83a200675a?version=5.20.2

Logs

System Info

n/a (only repl used)

Severity

blocking an upgrade

@paoloricciuti
Copy link
Member

This is expected and a documented breaking change

https://svelte.dev/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode-Bindings-to-component-exports-are-not-allowed

Thanks for reporting tho 😊

@paoloricciuti paoloricciuti closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2025
@KTibow
Copy link
Author

KTibow commented Feb 21, 2025

@paoloricciuti why doesn't it error/warn then

@Thiagolino8
Copy link

Ensuring the shape of an object (like the props object) is a job for TypeScript

@KTibow
Copy link
Author

KTibow commented Feb 21, 2025

very well, I was in the REPL and wasn't using TS and wasted a lot of time as the result

@WillsterJohnson
Copy link

Use of export let provides an error, as it isn't valid in runes mode.
Shouldn't export const (or any use of export) do the same? Afaik export is banned in runes mode.

Can this be reopened to track this missing error, or is it a duplicate of another issue?

@KTibow
Copy link
Author

KTibow commented Mar 8, 2025

@WillsterJohnson no you can still do it with bind:this={thing} then thing.property (which imo is really weird but technically works)

@paoloricciuti
Copy link
Member

@WillsterJohnson no you can still do it with bind:this={thing} then thing.property (which imo is really weird but technically works)

Correct

@Thiagolino8
Copy link

export let is prohibited because you are most likely wanting to create a prop with the svelte 3/4 syntax in mind than wanting to create an accessor
Eventually when the legacy syntax is removed the use of export let should be allowed again.
#10310 (comment)

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

No branches or pull requests

4 participants