sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.39k stars 4.1k forks source link

`migrate` fails on `$$Props` #13178

Open benmccann opened 1 week ago

benmccann commented 1 week ago

Describe the bug

The migration tool fails to migrate $$Props, which I didn't know existed until I tried to run it on some real-world projects and it bombed out upon encountering it 😆

A description of $$Props is here: https://www.reddit.com/r/sveltejs/comments/1778zq4/interface_props_mentioned_in_the_svelte_5_post/

migrate lives in this repo: https://github.com/sveltejs/svelte/blob/4f10c83d32ba5d289866093b7d3b514f3c540a3f/packages/svelte/src/compiler/migrate/index.js#L24

Reproduction

https://github.com/immich-app/immich/blob/8cf33690b8ddd8e36bdf5d968c3d5700bfcc2949/web/src/lib/components/shared-components/password-field.svelte#L7

Logs

No response

System Info

latest svelte 5 and unmerged migration tool PR

Severity

annoyance

dummdidumm commented 1 week ago

This is a tough one to fix. The problem is that the analysis phase errors on $$Props because it thinks this is an identifier. It does think that because it expects types to be stripped out before analyzing the AST (which is very sensible and more robust approach for the rest of the compiler). But for migration we can't strip out the types, because it means we wouldn't be able to properly modify the code afterwards. The only solution I see right now is to do some kind of quick hack where $$Props is replaced with something like _$$Props so the analysis doesn't throw.