I'm encountering strange behaviour with typedefs, and I wanted to check if I'm missing something obvious. I'd like to define a typedef in a source file, and have that typedef accessible from multiple other files that use it. Is that possible?
Here's a simple example, spread over two files, which distills out the behaviour I'm seeing:
--------- Thing.hx ---------
package;
typedef MyList = List<Int>;
class Thing { public function new() {} }
----------------------------------
------------ Main.hx -----------
package;
class Main {
public function new () {
var t = new Thing();
var a = new MyList();
}
}
--------------------------------------
As written, this program gives me "Class not found : MyList" at compilation time. That makes me think that Main.hx can't even see MyList. But that's not quite true, because if I add a copy of the typedef to Main.hx, I instead get "Type name MyList is redefined from module Main".
So -- what am I missing here? Is there some Haxe best practice that lets me define a typedef in one place and have it accessible everywhere?
Thanks.