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

docs: Switch typing of Action<Parameter> from null to undefined in 12-use.md #14798

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

felipesantoz
Copy link

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.

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

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