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

ActionData generated type missing some properties in the template because of the way it does union #8865

Closed
madupuis90 opened this issue Feb 3, 2023 · 1 comment · Fixed by #8877
Labels
bug Something isn't working types / typescript
Milestone

Comments

@madupuis90
Copy link

madupuis90 commented Feb 3, 2023

Describe the bug

This seems to be only a problem whenever you are using form actions with multiple named actions.
If you have multiple actions that return different objects, you will get "Property 'x' does not exist on type" errors from typescript.

This is a bit annoying since you then have to define your own types instead of using SvelteKit generated types.

(I'm not sure if this is a bug or intended)

Related ?:

Reproduction

https://github.com/madupuis90/form-actions-type-github

This is the simply a create svelte app using the form action examples from the docs (with implemented register function instead of commented)

If you look in +page.svelte you will see the invalid types. Commenting the register action clears the errors.

Logs

No response

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 46.58 GB / 50.16 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 19.2.0 - ~/.nvm/versions/node/v19.2.0/bin/node
    npm: 9.2.0 - ~/.nvm/versions/node/v19.2.0/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.2
    @sveltejs/kit: ^1.0.0 => 1.3.10
    svelte: ^3.54.0 => 3.55.1
    vite: ^4.0.0 => 4.1.1

Severity

annoyance

Additional Information

No response

@madupuis90 madupuis90 changed the title Make ActionData type generation an aggregation of all possible return types ActionData generated type missing some properties in the template because of the way it does union Feb 3, 2023
@dummdidumm dummdidumm added bug Something isn't working types / typescript labels Feb 3, 2023
@dummdidumm dummdidumm added this to the soon milestone Feb 3, 2023
Rich-Harris pushed a commit that referenced this issue Feb 3, 2023
* fix: ensure types of all form actions are accessible

fixes #8865

* THAS HAS
@madupuis90
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types / typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants