/hxtsdgen

TypeScript declaration file generator for Haxe JavaScript output target

Primary LanguageHaxe

TypeScript Declaration Generator for Haxe/JS

Build Status

STATUS: WORK IN PROGRESS, CONTRIBUTIONS WELCOME

This is a TypeScript declaration file generator for the Haxe JavaScript output target.

What it does is generate a .d.ts file next to the .js file generated by Haxe compiler, containing TypeScript declarations for classes and functions exposed from Haxe using the @:expose metadata.

Usage

Just add -lib hxtsdgen to compiler arguments and it'll do the rest.

Why?

To make using Haxe/JS modules from both JavaScript and TypeScript much easier, of course! Just compile your Haxe library to a JS module and use it in TypeScript in a perfectly typed way.

You may ask, how does plain JavaScript benefit here? Well, the thing is, modern JavaScript editors such as VS Code and (I think) IDEA, can download and use TypeScript "typings" for providing hints while editing JavaScript code.

How does it look?

Check out these 3 awesome panes (left-to-right):

  • Main.hx (Haxe source code)
  • main.d.ts (generated TypeScript declarations)
  • test.ts (TypeScript source code that uses the declarations)