Generated type ActionData
, is missing optional properties when fail()
returns different data
-shapes
#9727
Milestone
ActionData
, is missing optional properties when fail()
returns different data
-shapes
#9727
Describe the bug
This is only an issue with the generated
ActionData
-type, not the hydration of theform
-property.When an action is calling
fail()
multiple places, with different shapes of data, it seems that the generated type will be narrowed down to the shape, that only shares the common properties of all the possible shapes.This results to
Property 'x' does not exist on type 'y'
-errors, when trying to access those properties in the+page.svelte
componentThis seems like a bug. Though not of high severance, as it can be circumvented, by just adding the properties to
data
-objects where needed.Related:
Reproduction
https://github.com/jeppech/incorrect-actiondata-multiple-fail-fn
This is a plain
create-svelte@latest
-repo, that demonstrates how the generatedActionData
-type is missing optional properties.When the
data
-parameter offail()
, partially matches other shapes, in any other call to thefail
-function, the generated type will be narrowed down to the "common" properties of all shapes.Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: