I have been working on some TypeScript code and I seem to be having trouble getting it to work as expected. It would be greatly appreciated if someone could help me understand what I'm doing wrong or suggest a different approach.
Let's assume I have a Definition
that consists of a function named name
and data
.
interface Definition<TName extends string, TData extends any> {
name: TName;
data: TData;
}
The Definition
eventually transforms into an Action
. The Action
includes a function called method</code with <code>payload
as the first parameter type.
interface Action<TDefinition extends Definition<string, any>> {
name: TDefinition["name"];
method: (data: TDefinition["data"]) => void;
}
It is essential for all elements of the Definition
union to pass through the Changer
.
interface Changer<TDefinition extends Definition<string, any>> {
actions: Action<TDefinition>[];
}
...
What are your thoughts?