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

Incorrect types for __sveltets_2_SvelteTransitionReturnType? #2686

Open
jasonsparc opened this issue Feb 15, 2025 · 0 comments
Open

Incorrect types for __sveltets_2_SvelteTransitionReturnType? #2686

jasonsparc opened this issue Feb 15, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jasonsparc
Copy link

Describe the bug

I created a custom transition that returns a function of type (options: { direction?: 'in' | 'out' }) => TransitionConfig, which Svelte supports. See, https://github.com/sveltejs/svelte/blob/[email protected]/packages/svelte/src/internal/client/types.d.ts#L131

Apparently, in VS Code, I get the following error:

Image

Note that the error will disappear if I use () => TransitionConfig instead.

This shouldn't be the case though, since Svelte supports the optional { direction: 'in' | 'out' } parameter.

Reproduction

Here's a simplified example:

<script lang="ts">
	import { fade, type FadeParams } from "svelte/transition"

	function exampleTransition(node: Element, params: FadeParams = {}) {
		const result = fade(node, params)
		return (options: { direction: "in" | "out" }) => result
	}

	let items = $state(["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"])
	let i = $state(3)
</script>

<label>
	<input type="range" bind:value={i} max="10" />
</label>

{#each items.slice(0, i) as item}
	<div transition:exampleTransition>
		{item}
	</div>
{/each}

The transition:exampleTransition above will be highlighted as an error.

Expected behaviour

As I said before, that shouldn't be the case, since Svelte supports the { direction: 'in' | 'out' } parameter.

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@jasonsparc jasonsparc added the bug Something isn't working label Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant