What's the best way to attach functions to a TypeScript interface?

So I currently I have game objects with properties attached. For example, a creature card with properties attached. Now I have code like this:
const isSlow = card.properties.includes(Property.Slow);

I kinda hate this, especially if I have to write code like this all over the place.
Now ideally, I want to just put a predicate to the card so I implement it once and can just call
const isSlow = card.isSlow();

Is this possible with interfaces at all? Like an abstract prototype-ish implementation?

Some caveats:
  • I cannot use classes, cause that messes up my Redux state management and jsonifying states in general.
  • I also considered utility classes like
    cardFunctions
    then I guess you could do
    import { isSlow } from "./cardFunctions";
    const isSlow = isSlow(card);

    not the biggest fan but if that's the best there is I might go for it
Was this page helpful?