Is there a way to access an interface prop value within the same interface declaration in order to dynamically set types?
I am attempting something like this:
export type MethodNames = "IsFallmanagerUpdateAllowed" | "UpdateStammFallmanager";
export interface IsFallmanagerUpdateAllowed {
plcParameter : StammFallmanagerParameter
}
export interface UpdateStammFallmanager {
plcParameter : StammFallmanagerParameter
}
export interface ServerTaskParam<T> extends system.ServerTaskParam<T> {
name : `${Class.NAME}`,
methodName : MethodNames,
paramObj : // here depending on the passed methodname type should be IsFallmanagerUpdateAllowed or UpdateStammFallmanager
// paramObj : T -> this is what I use atm but I want to make it more dynamic
}
Note that there could be more MethodNames
.
The goal is for intellisense to indicate directly which type of object should be used as paramObj
when passing name and methodName.
If possible, it should be something like this:
export interface ServerTaskParam extends system.ServerTaskParam {
name : `${Class.NAME}`,
methodName : MethodNames,
paramObj : [ methodName ] -> use methodName value to refer to one or the other interface in the same namespace (pseudo syntax)
}
I have been searching online for solutions but haven't found anything. Is this concept feasible?