In Typescript, is there a way to describe the reject() call from a Promise, for the functions return type?
For example, I have a function, validate() that takes some JSON and checks it's valid. If it is, a resolve() is returned. Otherwise, a reject() is returned, with a simply object, containing the error(s).
Is there a way to describe the Promise<> return type, so that I know it can potentially fail and return the reject()?
A bit like PHP @throws annotation, so the IDE can help to indicate that the exception hasn't been handled.
This is not the same as Typescript Promise rejection type, as I am wanting to set the functions return type to describe that the function can result in a promise rejection being thrown (with the type of data inside them as a bonus)