Currently you can do:
this.dispatchTo(topicInstanceName, optional_activity, dispatchArgs);
If topicInstanceName points to an instance of MyTopic, dispatchArgs should match the typing of the arguments to the onDispatch on MyTopic. But right now there is no mechanism for doing that, so both are typed as any.
This is a tallish hill to climb.
On the child side we'd need a new generic Dispatch type for DispatchScore and Topic:
export interface DispatchScore <
Dispatch = any
> {
dispatchArgs?: Dispatch;
score: number;
}
export abstract class Topic <
Start = any,
State = any,
Return = any,
Constructor = any,
Dispatch = any,
Context extends TurnContext = TurnContext,
> {
...
async onDispatch(args?: Dispatch) {
}
...
async getDispatchScore (
activity?: Activity,
): Promise<DispatchScore<Dispatch> | void> {
}
...
}
On the parent side we can add a new signature to dispatchTo to let it take an actual class instance:
this.dispatchTo(instance_of_MyTopic, optional_activity, dispatchArgs);
We'd probably want to change things so that this signature is the only way to provide dispatchArgs, since it's the only typesafe one. That means no passing dispatchArgs to dispatchToChild. This is probably an okay limitation given how rare dispatch scoring even is.
But I'm not sure this ultimately buys us anything, because where does this mythical instance_of_MyTopic come from anyway? loadTopic which generically returns a Topic.
I don't think this can work.
Currently you can do:
If
topicInstanceNamepoints to an instance ofMyTopic,dispatchArgsshould match the typing of the arguments to theonDispatchonMyTopic. But right now there is no mechanism for doing that, so both are typed asany.This is a tallish hill to climb.
On the child side we'd need a new generic
Dispatchtype forDispatchScoreandTopic:On the parent side we can add a new signature to
dispatchToto let it take an actual class instance:We'd probably want to change things so that this signature is the only way to provide
dispatchArgs, since it's the only typesafe one. That means no passingdispatchArgstodispatchToChild. This is probably an okay limitation given how rare dispatch scoring even is.But I'm not sure this ultimately buys us anything, because where does this mythical
instance_of_MyTopiccome from anyway?loadTopicwhich generically returns aTopic.I don't think this can work.