-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
Props removed when saving #2594
Comments
You probably have the I can't reproduce auto-import adding import to after props. Can you provide a code snippet and instructions for reproducing it? |
Yeah it seems like a duplicate of #1590 Here is a video that shows when an import is added after the CleanShot.2024-11-19.at.10.10.26.mp4 |
And I forgot to confirm:
|
#2594 As a drive-by, I also ensures that the dts generation knows about the hoisted interfaces so it does not transform them into types anymore
Fixed the auto import, for the more general problem I defer to #1590 |
#2594 As a drive-by, I also ensures that the dts generation knows about the hoisted interfaces so it does not transform them into types anymore
Can confirm this is happening on 109.3.0. Example<script lang="ts">
import X from '...';
import Y from '...';
import Z from '...';
let { data }: { data: PageData } = $props();
</script> Turns into <script lang="ts">
import X from '...';
import Y from '...';
import Z from '...';
{ data: PageData } = $props();
</script> If I have any other top level variable declarations and put them before the <script lang="ts">
import X from '...';
import Y from '...';
import Z from '...';
let test = $state('');
let test2 = $state(true);
const test3 = "test3";
let { data }: { data: PageData } = $props();
</script> Turns into <script lang="ts">
import X from '...';
import Y from '...';
import Z from '...';
{ data: PageData } = $props();
</script> InterestinglyThe bug doesn't happen at all when using a named type for props instead of doing it inline <script lang="ts">
import X from '...';
import Y from '...';
import Z from '...';
type MyProps = {
data: PageData;
}
let test = $state('');
let test2 = $state(true);
const test3 = "test3";
let { data }: MyProps = $props();
</script> It could be related to one of my imports having side effects? Like maybe something declares a variable at the top level, but I haven't pinned that down yet as most of my imports are from 3rd party npm modules. For now though I'm just setting |
109.3.0 seems to introduce a new bug. When organize imports runs, it rewrites
to
Which makes 109.3.0 unusable for me. Just reverted to 109.2.4. Edit: Just saw @mcullifer comment. I have the same exact issue. |
Should be fixed in the latest release |
@dummdidumm I can still reproduce mcullifer's issue in 109.3.2 |
Please provide a complete code snippet that reproduces this |
The issues seems to be fixed for me with 109.3.2. |
<script lang="ts">
import {} from "svelte"
let {}: {} = $props()
</script> 102.3.2 formats to <script lang="ts">
import { } from "svelte"
{} = $props()
</script>
{
"editor.codeActionsOnSave": { "source.organizeImports": "always" }
} |
Also:
becomes:
|
Describe the bug
When VSCode adds an import automatically, it adds it under the
let { data }: { data: PageData } = $props();
, which then gets removed when saving, probably due to auto-formatting.Reproduction
let {data}
being deleted.Expected behaviour
Either the
import { error }
should be added before thelet { data }
initially, or the formatting tool places it at the correct place and do not delete thelet { data }
.System Info
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
The text was updated successfully, but these errors were encountered: