COMMUNITY

Is there a way to get Haxe to keep real types in Array type parameters?

I am noticing that in my generated C# code, Array<RealType> is always replaced with Array<object>; this is particularly an issue when extern classes, where I want to use the specific types, e.g. Array<RealType> but have to accept Array<object> to satisfy the C# compiler. Is there a way to tell haxe or hxcs to use the real types?

I don’t know any way to do that for Array.
For your own custom classes it’s usually possible by using @:nativeGen meta.
As a workaround, you can pass native arrays to/from externs:

var nativeArray = cs.Lib.nativeArray(haxeArray, true);

AFAIK type parameters for extern types don’t get replaced with object, and cs.NativeArray is an extern type.