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

[fix] make errors in Action less restrictive #6022

Merged
merged 2 commits into from
Aug 18, 2022
Merged

Conversation

dummdidumm
Copy link
Member

Part of #6015

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • 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. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2022

🦋 Changeset detected

Latest commit: 6e0e157

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

@benmccann
Copy link
Member

I think we added some type tests somewhere? Should we try to cover this with them?

@dummdidumm
Copy link
Member Author

@Rich-Harris removed them 😄 they were related to the JSONObject thing which we removed entirely. Such a simple change doesn't warrant a type test IMO.

@benmccann
Copy link
Member

benmccann commented Aug 18, 2022

Can the type really be any? I'd think it'd have to be something JSON serializable at least?

Ah, that's why I didn't know where they were anymore 😄 All types are conceptually simple, but we're always making small mistakes where we get things wrong. A test would prevent a regression and clarify how non JSON serializable objects should be treated

@dummdidumm
Copy link
Member Author

It has to be, yes, but it's impossible to type "this expects a JSON type", see #5974 for more info

@benmccann
Copy link
Member

benmccann commented Aug 18, 2022

For others, following that link, I found the explanation here: #5963 (comment)

I wonder if we should at least do something like:

export type JSONSerializable = any

...

errors: Record<string, JSONSerializable>

It doesn't change what's allowed but may help to document what's expected to clarify things for users

@Rich-Harris
Copy link
Member

Tried it just now, it doesn't work. TypeScript replaces it with the underlying value

image

Screenshot 2022-08-18 at 12 34 54 PM

@Rich-Harris Rich-Harris merged commit cfb6764 into master Aug 18, 2022
@Rich-Harris Rich-Harris deleted the action-type branch August 18, 2022 16:36
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.

3 participants