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

support number[]? #34

Closed sonygod closed 4 years ago

sonygod commented 4 years ago

from paper.js

add(...segment: (Segment | Point | number[])[]): Segment | Segment[]

and haxe code

@:overload(function(point:Point):Point { })
function add(number:Float):Point;

function onload() {
  var canvas:js.html.CanvasElement = cast Browser.document.getElementById('myCanvas');

  paper = Lib.nativeThis.paper;

  paper.setup(canvas);

  var path:Path = new Path();
  // Give the stroke a color
  path.strokeColor = new Color('black');
  var start:Point = new Point(100, 100);
  // Move to start and draw a line from there
  path.moveTo(start);
  // Note that the plus operator on Point objects does not work
  // in JavaScript. Instead, we need to call the add() function:
  path.lineTo(start.add([200, -50]));//here is wrong.
  // Draw the view now:
  paper.view.draw();
}
sonygod commented 4 years ago

may be it's wrong title .I 'm close.

haxiomic commented 4 years ago

This looks like a rest parameter with a union type, I know there’s issues with these and improvements to them are definitely planned :)