useActionState return type
Answered
Polar bear posted this in #help-forum
Polar bearOP
Is there a way to define a global type for the server action return type so all server actions can adhere to?
Answered by B33fb0n3
yes, you can set the return type of your server action directly to the function. Of course you can reuse the same type everywhere on all server actions: (see attached)
5 Replies
@Polar bear Is there a way to define a global type for the server action return type so all server actions can adhere to?
yes, you can set the return type of your server action directly to the function. Of course you can reuse the same type everywhere on all server actions: (see attached)
Answer
Polar bearOP
is there a way to set it globally like in a
.d.ts
file?@Polar bear is there a way to set it globally like in a `.d.ts` file?
I don't think so, as every function is unique and will only be transformed into a server action at runtime. But typescript is not there during runtime
@B33fb0n3 I don't think so, as every function is unique and will only be transformed into a server action at runtime. But typescript is not there during runtime
Polar bearOP
thank you, your suggestion is fine also.
sure thing