Sounds awesome!
It's probably enough to typecheck the generated code (and convert the runtime libs to TS, or at least for during type checking).
My main concern would be encoding. Encode as a class Behavior that is a subtype of Event, and does that play nice w/ their generics system & all our sugar?
Re:spacetime leaks, those don't exist in Flapjax's CBV model of FRP. In Rx parlance, every value is 'hot' :) So, generics/classes should be fine for what the lazy language systems worry about. There may still be a different (and lesser) kind of leak relating to lack of weak references. Awhile back I tried figuring out if WeakMap would help, but seemed close-but-no-cigar..
- Leo
Flapjax behaviors are basically 'a * Event 'a, and most operators will coerce to Event 'a as needed (but not the other way around, as that is less sensibly defined). Due to the chaining sugar, it probably makes more sense to model as classes Behavior <: Event.
An issue I believe Arjun worked on in his thesis work is how all the helper methods got added to the ~class. He invented new types to describe ~metaprogramming here, but also rewrote code to make the job easier.