haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
134 stars 9 forks source link

how to support var fillColor : Null<Color|String>;? #35

Closed sonygod closed 4 years ago

sonygod commented 4 years ago

how to support var fillColor : Null<Color|String>;?

from paper.js

path.fillColor=new Color(...);

or

path.fillColor="red"
haxiomic commented 4 years ago

This should work, it should use ts.AnyOf2<>, what does the converted haxe code look like?

haxiomic commented 4 years ago

This is a problem with the types of paper.js,

Checking paper.d.ts in node_modules/paper after npm install paper:

        /** 
         * The fill color.
         */
        fillColor: Color | null

Which is correctly translated to

    /**
        The fill color.
    **/
    var fillColor : Null<Color>;