Using NeverThrow with "Use Server"

How does one return a funciton with the type of Result Async without the linter complaining that a "use server" file can "only export async functions. Add "async" to the function declaration or return a Promise"

I managed to do a hacky workaround by undoing NeverThrow's Result Async type, but this disbars you from using any of the other Result Async methods since it's seen as a normal promise.

I feels like I'm missing some type extension or should just modify the actual lint rules.


I've attached some code below outlining my current solution/predicament.

"use server"
type HackyType=Promise<Result<"yay", "nay">>
export async function dbCallHacky(): HackyType{
....
//this fn returns a result async  but it's return type has to be promise
return ResultAsync(...)
}

/* linter error:
The "use server" file can only export async functions. Add "async" to the function declaration or return a Promise.
*/
export async function dbCallIdeal():ResultAsync<"yay","nay">{
....
return ResultAsync (...)
}
Was this page helpful?