-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support shared properties of type unions #105
Comments
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 |
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 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.
|
ts.AnyOf issue.
some gen class have some fields like
//is possible to do something like that?
The text was updated successfully, but these errors were encountered: