kit
kit copied to clipboard
fix: check for wrong return values from form actions
Related to #8523
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.
Tests
- [x] Run the tests with
pnpm testand lint the project withpnpm lintandpnpm check
Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.
🦋 Changeset detected
Latest commit: 190ef64ac055630c3fe7294fac911e4bfefe994d
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @sveltejs/kit | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Related to https://github.com/sveltejs/kit/issues/8523
Should this close that issue or is there more to do?
It's related because the last comment in there comes from wrong usage, but the messages before that sound mysterious, so I'd like to keep it open at least until Rich can have a look - he probably knows more about what changed in devalue recently that could have caused this.
I think validation should only happen in dev, so I amended the PR (I also think we should strive to keep side-effects and return statements separate, as it makes code easier to follow).
However, doing so revealed an issue with the types — we previously had this...
data: /** @type {Record<string, any> | undefined} */ (data)
...and removing the annotation caused an error...
Type 'void | Record<string, any>' is not assignable to type 'Record<string, any> | undefined'
...that I think is best fixed by changing the interface from data?: Success to data: Success | void which more accurately reflects the ground truth. But I'll hold off merging for the moment in case that's the wrong answer