Define commands on-the-fly without creating a class #3026
-
The following interface should be implemented (by a class) in order to define a synchronous command: interface Command<Model extends object, Real> In addition to that, can a command be defined as a pair (or actually a triple) that holds the functions (Or, perhaps TypeScript has something similar to F# Object Expressions where you can implement an interface on-the-fly, without having to create a class.) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I think the on-the-fly should work fine with https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/src/arbitrary/commands.ts#L40. The interface is mostly there to give the typing related contraints but not for extends needs (at least for the ICommand and derived stuffs). |
Beta Was this translation helpful? Give feedback.
-
Can confirm, I use commands without a class: type Command = fc.AsyncCommand<Model, Real>
const createCommand = (): Command => ({
check: (m) => true,
// ... etc.
}) |
Beta Was this translation helpful? Give feedback.
Can confirm, I use commands without a class: