Skip to content

Conversation

@felipesantoz
Copy link
Contributor

Currently, the docs for use: give an example of using the Action interface to type an action. In it, null is specified as the optional type argument for the parameter. Unfortunately, this means the example leads to the following type error in practice, on the line where use:gestures is contained: Expected 2 arguments, but got 1.

The solution is to switch the type argument for the parameter to undefined. This gets rid of the type error, accomplishes the intended behaviour, and matches the default value for the generic to begin with.

No testing required as it is a documentation change. To recreate the type error simply copy and paste the example into any svelte project. I couldn't figure out how to get the playground compiler to do type-checking in svelte files to show it directly, or if it's even possible.

@changeset-bot
Copy link

changeset-bot bot commented Dec 21, 2024

⚠️ No Changeset found

Latest commit: 5399535

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-svelte-14798-svelte.vercel.app/

this is an automated message

@Rich-Harris Rich-Harris merged commit 8201d7a into sveltejs:main Jan 7, 2025
1 check passed
@Rich-Harris
Copy link
Member

thanks!

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

Successfully merging this pull request may close these issues.

2 participants