Thanks @tsnobip for the reply. I did not know about the @as argument which solves part of the problem.
The other issue is that the type and number of parameters to “When” (or other step functions) can vary from nothing to string or string and string, or table (string[][]), etc.
Current TS type is this:
type Operation = (...params: any[]) => void;
The exact parameters are extracted from the string by detecting numbers and quotes.