Open sonygod opened 2 years ago
I’m not sure I follow - could you explain a bit more? What does the source typescript look like?
Do you mean those properties are shared between types A and B and should be accessible within the AnyOf?
I have a plan for this but it requires macros, it’s in the roadmap but less critical than other features
Do you mean those properties are shared between types A and B and should be accessible within the AnyOf?
yes ,I mean those properties are shared between types A and B,because we have a project use native js ,there are lots of these
style something like
class SomeClass {
var geometry : ts.AnyOf2<A,B>;
}
var sc=new SomeClass ();
sc.geometry .AProperty=1;
var sc2=new SomeClass ();
sc.geometry .BProperty=1;
I convert to haxe I have to write lots of cast ugly code ...
cast (sc.geometry,A) .AProperty=1;
cast (sc.geometry,B) .BProperty=1;
Agreed, it can be solved with a type building macro which is on the roadmap I'll rename the issue and leave it open
btw this also works
sc.asType0.AProperty = 1;
sc.asType1.BProperty = 1;
there is more complex in three.js
class SomeClass {
var geometry : ts.AnyOf2<AParent,BParent>;
}
var sc=new SomeClass ();
sc.geometry .AChildClasssProperty=1;//native js direct support child's property.
Mesh.hx
extern class Mesh extends Object3D
var material : ts.AnyOf2<Material, Array<Material>>;
myobject .material.color.set(iColor);//base Material have no color property
myobject.material.needsUpdate = true;//base Material have no needsUpdate property
@haxiomic ,dts2hx 0.18.1 seem support this ? I will close this issue.
three.js 0.135
seem resolution this issue.
Line<TGeometry, TMaterial> and extern class Mesh<TGeometry, TMaterial>
var geometry : TGeometry;
var material : TMaterial;
ts.AnyOf issue.
some gen class have some fields like
//is possible to do something like that?