Is there a way to define a function type that can return any value except a Promise?
This is how my interface currently looks:
interface AnInterface {
func(): AllowAnythingButAPromise;
}
I have attempted the following:
type AllowAnythingButAPromise<T> = T extends Exclude<any, Promise<any>> ? T: never;
type AllowAnythingButAPromise<T> = T extends Exclude<any, Promise<unknown>> ? T: never;
type AllowAnythingButAPromise<T> = T extends Promise<unknown> ? never : T;
type AllowAnythingButAPromise<T> = T extends Promise<any> ? never : T;
type anything = number | symbol | string | boolean | null | undefined | object | Function;
type AllowAnythingButAPromise<T> = T extends Exclude<anything, Function> ? T: never;
However, I haven't had success with this approach. Is it even possible to achieve what I am trying to do?