Hi,
I'm having trouble coming up with a JS extern for a library interface that has a couple oddities... Alright, I think the interface is actually the antithesis of type-safety. Here's my example code:
1) First, I can't seem to describe a static accessor from one extern class to another (to get to MJ.Hub.Queue). The error is:
Test.hx:16: characters 8-20 : Class<Hub> has no field Queue
I'm sure I just did something dumb.
2) Second, the Queue function signature is a real pain. It operates on (a variable number of) arrays of mixed type... and each of those arrays has a variable number of args and comes in two flavors, either [String, Dynamic, ...args] or [Function, ...args]
The above example runs great, until you uncomment that little untyped keyword. Then the compiler explodes in anger.
It would be nice to get as close to the existing function signature as possible, but I can't imagine how to retain it and get type safety. Here's what I could maybe come up with:
- Lose the outer ...args on Queue and just call it multiple times, with either flavor with @:optional.
- Create two different type-safe helper functions to load up an Array<Dynamic> one element at a time, or
- Use a macro that intelligently type checks the args for me, or
- give up and stick with untyped :(
None seems like an ideal choice. I just want to be sure I'm not missing something obvious wrt specifying Arrays of mixed type.
Thanks!
-Jeff