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

Migration: Add correct type for bind:this of Components when using the migration script #13491

Open
FoHoOV opened this issue Oct 3, 2024 · 0 comments · May be fixed by #13656
Open

Migration: Add correct type for bind:this of Components when using the migration script #13491

FoHoOV opened this issue Oct 3, 2024 · 0 comments · May be fixed by #13656
Assignees

Comments

@FoHoOV
Copy link
Contributor

FoHoOV commented Oct 3, 2024

Describe the problem

In svelte 4 when typing the bind:this we used this:

<script lang="ts">
	import Component from "./Component.svelte";

	let comp: Component | undefined = undefined;

	onMount(()=>{
		comp.sayHi();
	})
</script>

<Component bind:this={comp} />

After running the migration script nothing changes whilst it should be:

<script lang="ts">
	import Component from "./Component.svelte";
	import {onMount} from "svelte";

	let comp: ReturnType<typeof Component> = undefined;

	onMount(()=>{
		comp.sayHi();
	})
</script>

<Component bind:this={comp} />

Describe the proposed solution

Use ReturnType<typeof X> or use the utility type in #13441 which makes bind:this type forward-compatibale - easier to change internally without requiring change on the comsumer code.

here is the REPL

Importance

would make my life easier

@FoHoOV FoHoOV changed the title Add correct type for bind:this when using the migration script Add correct type for bind:this of Components when using the migration script Oct 3, 2024
@FoHoOV FoHoOV changed the title Add correct type for bind:this of Components when using the migration script Migration: Add correct type for bind:this of Components when using the migration script Oct 3, 2024
@paoloricciuti paoloricciuti self-assigned this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants