kit icon indicating copy to clipboard operation
kit copied to clipboard

fix: check for wrong return values from form actions

Open dummdidumm opened this issue 2 years ago • 3 comments

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 test and lint the project with pnpm lint and pnpm 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 changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

dummdidumm avatar Jan 16 '23 12:01 dummdidumm

🦋 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

changeset-bot[bot] avatar Jan 16 '23 12:01 changeset-bot[bot]

Related to https://github.com/sveltejs/kit/issues/8523

Should this close that issue or is there more to do?

benmccann avatar Jan 16 '23 14:01 benmccann

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.

dummdidumm avatar Jan 16 '23 15:01 dummdidumm

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

Rich-Harris avatar Jan 17 '23 21:01 Rich-Harris