I’m writing a unit-testing library for TypeScript and I managed to trick the TypeScript transpiler into letting me snoop on function calls using some cursed JavaScript hackery. and now I have a class that has a static .attach(func) method that will call .onCalled(args, returnValue) whenever func is called
the type annotations are truly fucking hideous but it works, and it’s incredibly helpful for creating mocks