fix(types): better types for TypedRouter.routeAndAddResponse

This commit is contained in:
Philipp Kunz 2021-11-07 14:56:48 +01:00
parent 9a07817914
commit ea56e2218f
3 changed files with 3 additions and 2 deletions

View File

@ -21,7 +21,7 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
public method: string;
/**
* note the overloading is thought to deak with promises
* note the overloading is thought to deal with promises
* @param postEndPointArg
* @param methodArg
*/

View File

@ -91,7 +91,7 @@ export class TypedRouter {
* if typedrequest object has correlation.phase === 'response' -> routes a typed request object to request fire event
* @param typedRequestArg
*/
public async routeAndAddResponse(typedRequestArg: plugins.typedRequestInterfaces.ITypedRequest) {
public async routeAndAddResponse<T extends plugins.typedRequestInterfaces.ITypedRequest = any>(typedRequestArg: T) {
if (!typedRequestArg?.correlation?.phase || typedRequestArg.correlation.phase === 'request') {
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);

View File

@ -6,6 +6,7 @@ export type IPostMethod = (
) => Promise<plugins.typedRequestInterfaces.ITypedRequest>;
/**
* this is an alternative to a post url supplied in `new Typedrequest(new TypedTarget(...), 'someMethodName')`
* enables the use of custom post functions
* used for things like broadcast channels
* e.g. @designestate/dees-comms