Simn / ts2hx

Typescript external definitions to haxe converter
80 stars 16 forks source link

support callable objects #14

Open nadako opened 9 years ago

nadako commented 9 years ago

TypeScript supports callable objects with multiple signatures. We could support this with the new @:selfCall metadata. So, we define a new method by some convention (how do we avoid potential name clashes?) adding all signatures as @:overload and append @:selfCall to it.

Also there are cases like this one: https://github.com/borisyankov/DefinitelyTyped/blob/1d08e36fe3ce81715cb956223f7e5a0a9882cd63/node/node.d.ts#L1341, maybe we should translate that var into an overloaded function.

back2dos commented 9 years ago

The authors of node's assert module went the extra mile for throws to be usable as a first class value. Meaning that you can get require('assert').throws and pass that around. They did by hand what $bind does for us automagically for methods and the .d.ts reflects that. I would just honor it.