Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/react/canary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ declare module "." {
export function unstable_useCacheRefresh(): () => void;

interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
functions: (formData: FormData) => void;
functions: (formData: FormData) => void | Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you want this to be Promise | undefined instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you think that?

}

export interface TransitionStartFunction {
Expand Down
14 changes: 14 additions & 0 deletions types/react/test/canary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ function formActionsTest() {
Delete
</button>
</form>;

<form
action={async (formData) => {
// $ExpectType FormData
formData;
}}
/>;

<form
// @ts-expect-error -- Type 'Promise<number>' is not assignable to type 'Promise<void>'
action={async () => {
return 1;
}}
/>;
}

const useOptimistic = React.useOptimistic;
Expand Down
2 changes: 1 addition & 1 deletion types/react/ts5.0/canary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ declare module "." {
export function unstable_useCacheRefresh(): () => void;

interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
functions: (formData: FormData) => void;
functions: (formData: FormData) => void | Promise<void>;
}

export interface TransitionStartFunction {
Expand Down
14 changes: 14 additions & 0 deletions types/react/ts5.0/test/canary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ function formActionsTest() {
Delete
</button>
</form>;

<form
action={async (formData) => {
// $ExpectType FormData
formData;
}}
/>;

<form
// @ts-expect-error -- Type 'Promise<number>' is not assignable to type 'Promise<void>'
action={async () => {
return 1;
}}
/>;
}

const useOptimistic = React.useOptimistic;
Expand Down