I started a small repo of js externs here:
Rather than manually writing externs, I'm trying to generate them directly from jsdoc-annotated files. Furthermore, I'm trying to use the closure compiler-specific additions to the jsdoc syntax, since they add additional type information that is useful in several situations (e.g. callback argument types). Furthermore, Google has a small repo of these externs that they track for their closure compiler project. You can see some of them here:
So, for now, I'm only focusing on what they provide as part of their main closure compiler repo. I'll add more in later on.
To help generate the externs, I'm writing a small template plugin for jsdoc. Naturally, the plugin is in Haxe, using the js target:
However, rather than generating html pages, the template writes haxe externs. Right now, the plugin is the only way I'm planning on updating the externs in hxtern. So, every time the jsdoc3-hxtern plugin changes, hxtern will update. I'll add in some testing, etc. that helps me track changes and problems in the plugin.
The plugin seems to work pretty well, but there's definitely a "good, bad, and ugly" side to this.
The Good:
I've created several enums and typed information for a jsdoc "Doclet", and parsing information from the closure compiler annotations. The information extracted from the javascript itself is pretty well structured.
The Bad:
Converting certain js types and entities to Haxe can become convoluted. I talk about some of it in the readme. The biggest issue (for me) is the problem of "union types" in arguments:
Javascript typically allows for dynamic arguments (e.g. strings, ints, arrays etc). Haxe can handle this somewhat by using @:overload. However, if there are multiple dynamic arguments, the number of overload definitions increases exponentially, since you have to specify each possible permutation of arguments. I was thinking this would be a case for union types. What's the best way of managing union types in Haxe externs? I see references to this idea, and even a deprecated library, but nothing recent.
Right now, I'm only using the first type from a javascript union type.
The Ugly:
No tests, and barely readable code in Publish.hx. I went back and forth between trying to structure everything in terms of enums and typedefs, and then trying to do something quick and dirty with annotating dynamic objects. It's somewhere in the middle right now.
Best,
-Justin