-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
Not sure whether this is just me missing something. But a couple of things seem not to be working in a route with actions.
In the page component:
- The generated
ActionData
type seems stubbornlyunknown
. I tried restarting the typescript and svelte language servers, stopping and restartingnpm run dev
,npm run check
and restarting VSCode, all to no avail. - The
export let form: ActionData
never seems to get populated after an invalid submission.The form does work when it is valid, however.The action does work as I wrote it, however, redirecting on success and staying on the same page when I returninvalid(...)
.
Here's what I'd expect to happen:
For (1) I'd assume that the generated ActionData
would be inferred from the return type of my default
action.
For (2) note that I've only gotten so far as trying a plain POST request, with no enhancement. I'd expect that export let form
would contain something other than undefined
after an invalid submission. Without resolving (1) it's hard to know what that something should be.
Anyway, I think I've read the docs correctly, but let me know if I've missed something. Thanks.
Reproduction
https://github.com/cdcarson/issue-sveltekit-generated-actiondata-type-undefined.git
The relevant route is in src/routes/prefs
.
To see that ActionData
is unknown
:
- Run the app to generate types
- Open
src/routes/prefs/+page.svelte
- Hover over
form
to get the type
To see that form
never gets populated:
- Run the app and navigate to http://localhost:5173/prefs
- Enter "kapoor black" as your favorite color and submit. This is a forbidden color, so the action returns
invalid(...)
. But somehow nothing is getting into the template, AFAICT. - Enter "blue" and submit. This will work and you will be redirected to the home page.
Logs
No response
System Info
System:
OS: macOS 12.5.1
CPU: (8) arm64 Apple M1
Memory: 148.02 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
Browsers:
Chrome: 105.0.5195.52
Safari: 15.6.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.71
@sveltejs/kit: next => 1.0.0-next.472
svelte: ^3.44.0 => 3.50.0
vite: ^3.1.0 => 3.1.0
Severity
blocking an upgrade
Additional Information
No response