{"_id":"ts2hx","_rev":"31-3a30be701e59c6f7f398ca0dbf32c649","name":"ts2hx","description":"Transpile Typescript to Haxe.","dist-tags":{"latest":"1.1.9"},"versions":{"1.0.0":{"name":"ts2hx","version":"1.0.0","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","dependencies":{"commander":"^2.5.0","lodash":"^2.4.1","ts2json":"^1.0.5"},"gitHead":"8fbc76f90d4136aa174062c7d76de0d34707c6a9","_id":"ts2hx@1.0.0","_shasum":"8a6950319c66e5bb2d8d986a0e552fdc2bc8bf95","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"8a6950319c66e5bb2d8d986a0e552fdc2bc8bf95","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.0.0.tgz","integrity":"sha512-3IK1v+mVjJzxTbopSnfyXQuuWnHS+4TbsSOqe7bco89V0aa0nZqm7aMT6bqNYdo/DgY3U/6fSN/OxYwjosbQNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHS+OEky8PVJC88vcslNLpT21hbSQBmfF3si++y4MTXfAiEA6dI8CP+hLvpyMezYfN+Lhn5GJbC+95XXdKKYLS16ZsM="}]}},"1.0.1":{"name":"ts2hx","version":"1.0.1","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","lodash":"^2.4.1","ts2json":"^1.0.5"},"gitHead":"8fbc76f90d4136aa174062c7d76de0d34707c6a9","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.0.1","_shasum":"218e329fd9b1a4c7aec19b3665ed4dec85e9c05b","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"218e329fd9b1a4c7aec19b3665ed4dec85e9c05b","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.0.1.tgz","integrity":"sha512-SjC3jSH0OLBWLfOdYzUJb24c//ug1oo543Yl1RbKPqsEqgolILQ1G0TxDTd8pEkv+4yK/O9cqKDrJTcspB8/hg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID5FFeNcKJGpcYfkJRqTtfDKV/qsXPH/WRbMnRj1rF9bAiEAohbMQucshe0auxw9z2GDW7qsBI/RTPI6kMSA71M3r8o="}]}},"1.0.2":{"name":"ts2hx","version":"1.0.2","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","lodash":"^2.4.1","ts2json":"^1.0.5"},"gitHead":"25e6029375103455a516cf8af6594a2749bdfab4","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.0.2","_shasum":"154667812c87c74572f2fefd3d8682509674b52a","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"154667812c87c74572f2fefd3d8682509674b52a","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.0.2.tgz","integrity":"sha512-TGjFflPZeYIlW3ZmLwJ92I9SxkWwXofpsP9oG7mZrX7i1/EOpM35NeZ7laN5cmN2T/OTmiZcN5rneePISJn8PQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCr9YJp5g9sqSYlqzUuLrLrEeZSzg9pXfsV6V9OgkYv8QIhAOV7MEuMaXUy1+poZXpAdpu2BIJybYXPDh0I9pbfPSBx"}]}},"1.1.0":{"name":"ts2hx","version":"1.1.0","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts2json":"^1.0.5"},"gitHead":"02b76073322a4a33f0c6401a44c7c44cfa5d091c","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.0","_shasum":"5f9da2a471a518ce2ab62d548a640f507266187d","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"5f9da2a471a518ce2ab62d548a640f507266187d","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.0.tgz","integrity":"sha512-nuxONFNdZtO0caU9G3etVGKTKCXUQtLwgzVspxacrlLjkfIyAXm+XOCoDGYtDCPaqBbq+44QkqV+dBS68u1dfA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9lyWvpp9pPW57eLDT7Z7sSXZa0bJ7T0vNm53kNdvsGwIhAL728W9KgS24W8Xw4R37fYVxgyzDXHe6D7Di1J8yKUJF"}]}},"1.1.3":{"name":"ts2hx","version":"1.1.3","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"3c8964b5515218d40d5799c1a3f89a214805cdbf","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.3","_shasum":"bd0e27ee6e580d1bd66e70d8fa4d723287c9305b","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"bd0e27ee6e580d1bd66e70d8fa4d723287c9305b","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.3.tgz","integrity":"sha512-2hcVwdPjrQhTzUUIUmlWxJcZAFyeOpWBRyK+0CFozpHmcnXlwmc5yPa9FRzFQ51Kdn2IEhpvnlZ9SoZSMkFtYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDRRZk9MzDMs7QFTanStVVMiuE4OUyiA7dqjKCOUD2ozgIhAJvSQBV6yyJzOVeDJEz+FB4m0++OrG10WNrtSlr+yuJD"}]}},"1.1.4":{"name":"ts2hx","version":"1.1.4","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"9785b2019290886badd077f4270b96367712e836","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.4","_shasum":"cc6518adb7481989f9117d557ff49fe33295103d","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"cc6518adb7481989f9117d557ff49fe33295103d","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.4.tgz","integrity":"sha512-T/ivQdQIxTgAv+S11gEj63OYq3CUjkCheL6n6PdpBqBk69QmDJ7XZyr7CKVj+Lkn9DKsKtR5QDUk+9S7eYTI9A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHSEHyYdjFwdSijcp74kUDq5aNxQiQXUWZy+W9njoBYVAiBbwYxErrsGN3qWqrigUWDRnO5BS2Tp1QYnw1y0JJwVFQ=="}]}},"1.1.5":{"name":"ts2hx","version":"1.1.5","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"5885f826160ae8c197aae203e6351910cb31edd1","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.5","_shasum":"e924055d522637da5ba2b750839743cab5836d36","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"e924055d522637da5ba2b750839743cab5836d36","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.5.tgz","integrity":"sha512-TswZnPVm8hxIfg9H9L7eBYPx5pbrbS33ZfOMJ0ZLu9mgFSdQhEZtwSCOeMz3Q+utMddX4nrxWjTJfS6mnbk+Gw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICu/EBeAXMy05iE9pLUDBHiEXukkUiqpFbZxH9QdoFfZAiEA+V/LWBRNEu9k0anj4C3KnYklbGH3u0vONmcTWLH3mlg="}]}},"1.1.6":{"name":"ts2hx","version":"1.1.6","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"1f39d75fc762f17c77003a0ca15ab8534d053302","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.6","_shasum":"f5fc98898906f1ba80b8630e80c98fd29f2c5892","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"f5fc98898906f1ba80b8630e80c98fd29f2c5892","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.6.tgz","integrity":"sha512-u+V81j8HwJrQn2oOElNqKDQo98NMzKce3K8V8kaAcV9/XNfqa5KbIeNFPsQsmv6/nRY5C5EyS3eZdH8pnr1cGg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAT7XsBSid25OYG4/tYtK+AIn8iu+imqlRmeAc3gALewAiEAk4ba3fG/jRzbyJZYBdMhq7ugFI56lGWalQFTrN96B7s="}]}},"1.1.7":{"name":"ts2hx","version":"1.1.7","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"a1ee848e2169b77698adbebe52afa55ae7560638","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.7","_shasum":"149725654fcea6f65180cd5f850ad354a7dd1e8e","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"149725654fcea6f65180cd5f850ad354a7dd1e8e","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.7.tgz","integrity":"sha512-arkX1kTfEbQAeTj/bd43gFS9I2fOtKyOaIAiowt79YgM0WrpNp6gqQA6LesxxvrtL7oeg4WUD/FjwTl9x4UmkQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXFpVzHymVrDm3ON/Ol8SPBkp6zqFN33uuGA/qbDN0wAIhAI7NNG5hYTinhN+eccKqrDguk5sr2sjsbRBmcG9huEfm"}]}},"1.1.8":{"name":"ts2hx","version":"1.1.8","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"7ae6552ee751f70d1f6f89af44e7788f019c835f","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.8","_shasum":"47cc53ff6fa69610bd6f1b6d93bd6253f3ef840e","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"47cc53ff6fa69610bd6f1b6d93bd6253f3ef840e","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.8.tgz","integrity":"sha512-Zg4GJZBdqMZjejwcRz7gEzc7P8GTOd5E8mCu0vFiIhlHRkiyDaE1ZFDAzuLX8LlWz2RL2lUrUjdbqfbLg7HE2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBRY4gHVAJh4V8pzyM6vxZkwsQXOmDLk4QgHy/2+NoLOAiEAlMBADAxq5WiQiEq322Dtk0wDUMYVTpJbJJ6eGXT/990="}]}},"1.1.9":{"name":"ts2hx","version":"1.1.9","description":"Transpile Typescript to Haxe.","main":"src/ts2hx.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"ts2hx":"./src/cli/ts2hx"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"dependencies":{"commander":"^2.5.0","fs-extra":"^0.12.0","glob":"^4.0.6","lodash":"^2.4.1","persist":"^0.2.7","ts-orderer":"^0.1.1","ts2json":"^1.0.5"},"gitHead":"a8c9c170ba9517625a1e5835cef3a19569b0d3af","bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"},"homepage":"https://github.com/jeremyfa/node-ts2hx","_id":"ts2hx@1.1.9","_shasum":"42a12b88d91e037cf3f397badacaa6b6db71fcf4","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jeremyfa","email":"contact@jeremyfa.com"},"maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"dist":{"shasum":"42a12b88d91e037cf3f397badacaa6b6db71fcf4","tarball":"https://registry.npmjs.org/ts2hx/-/ts2hx-1.1.9.tgz","integrity":"sha512-c44Qez6XPJ/9dDurjPXe0ozwNnTlt5Sm+hFxxVPb3rCvuDP2n7HxerG3B2gTVnlhGjSMiKlwMt55EHQVGUsxpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2zvBTZo7PjezhY64LodOQvu4cd+G0pya20LjvTTdHYAiBz6/7WyGZCtJJlHGcBaXmPnJmTLGSh35sw9erdvFJJkQ=="}]}}},"readme":"ts2hx\n=====\n\nCompile/Transpile typescript code to **ready-to-run** haxe code.\n\n### Why?\n\nI really like **Haxe** (http://haxe.org) and **openFL** (http://openfl.org) projects but I couldn't find a proper Haxe IDE on Mac that could suit my needs completely. However, Typescript is officially supported by several IDEs (Webstorm/IntelliJ, Visual Studio), making it very convenient to use. Then came the idea of writing a Typescript to Haxe transpiler. Typescript got ECMAScript roots and static typing which are pretty similar to Haxe.\n\nUsing ``ts2hx``, I am able to compile a **pixi.js**-based (http://pixijs.com) HTML5 app written in Typescript and make it work at **almost native speed** on mobile devices with **openFL** CPP target (yes, it becomes possible to compile Typescript to C++!). The only code that needs to be re-written in Haxe is the platform-specific code (use **openFL** API instead of **pixi.js** etc...). If all the platform-specific code is properly encapsuled in reusable classes, the rest of the code (all the app logic) can become 100% portable and compilable to **valid haxe code**.\n\nThat said, keep in mind this project is still **experimental**.\n\n## How to use\n\nInstall package\n\n``npm install ts2hx``\n\nExample\n\n```javascript\nvar ts2hx = require('ts2hx');\n\n// Compile typescript code\nvar haxeCode = ts2hx([\n    \"class FooClass {\",\n    \"    constructor(public name:string) {\",\n    \"        console.log('Hello, my name is '+this.name);\",\n    \"    }\",\n    \"}\"\n].join(\"\\n\"));\n\n// Log haxe output\nprocess.stdout.write(haxeCode);\n```\n\nExpected output:\n\n```haxe\npackage;\n\nclass FooClass {\n\n    public var name:String;\n\n    public function new(name:String) {\n        this.name = name;\n        trace('Hello, my name is ' + this.name);\n    }\n\n}\n```\n\n## Command Line Interface\n\nYou can install the cli command:\n\n``npm install -g ts2hx``\n\nThen run it:\n\n``ts2hx someFile.ts > result.hx``\n\nYou can also build a full directory of typescript files (recommended):\n\n``ts2hx --typescript dir/to/typescript/files --destination dir/to/compiled/haxe/files``\n\nWhen building a full directory, **ts2hx** will be able to perform additional tasks:\n\n - Add ``override`` keyword on methods overriding a parent class method (when the parent class is in the project)\n \n - Add in the final directory a support file ``Ts2Hx.hx`` required in some cases to make transpiled files work fine.\n \n - Replace some compiled files with original haxe files if needed (using ``--haxe`` option), allowing to use alternative implementations of specific classes in Haxe.\n\n\n## Compilation rules\n\nWhen compiling a typescript file, **ts2hx** performs conversions to make the haxe code behave the same as its typescript counterpart.\n\n### Core types\n\n**Typescript**\n\n```typescript\nvar foo:number = 1;\nvar bar:string = \"Hello\";\nvar baz:boolean = true;\nvar qux:any = { some: 'values' };\n```\n\n**Haxe**\n\n```haxe\nvar foo:Float = 1;\nvar bar:String = \"Hello\";\nvar baz:Bool = true;\nvar qux:Dynamic = { some: 'values' };\n```\n\n### Integers\n\nThe ``Int`` type doesn't exist in typescript. However, it is still possible to transpile ``number`` to ``Int`` when transpiling thanks to type inference or a custom typescript interface ``integer``.\n\n#### Add the  ``integer`` type in typescript\n\nAdd a typescript definition file to your project (integer.d.ts)\n\n```\ninterface integer extends number {}\n```\n\nYou can then use ``integer`` in your typescript code while still manipulating numbers in compiled javascript:\n\n**Typescript**\n\n```typescript\nvar foo:integer;\nvar bar:number;\n```\n\n**Haxe**\n\n```haxe\nvar foo:Int;\nvar bar:Float;\n```\n\n#### Integers by type inference\n\nIf you really don't want to use ``integer`` interface, you can still create haxe ``Int`` using type inference:\n\n**Typescript**\n\n```typescript\nvar foo = 1;\nvar bar = 1.0;\n```\n\n**Haxe**\n\n```haxe\nvar foo:Int = 1;\nvar bar:Float = 1.0;\n```\n\n### Enum\n\n**Typescript**\n\n```typescript\nenum EnumExample {\n    VALUE1,\n    VALUE2,\n    VALUE3,\n    VALUE4,\n    VALUE5\n}\n```\n\n**Haxe**\n\n```haxe\nenum EnumExample {\n    VALUE1;\n    VALUE2;\n    VALUE3;\n    VALUE4;\n    VALUE5;\n}\n```\n\n### Switchs\n\nThe ``break`` keyword in ``switch`` statements doesn't exist in haxe. Fall-through cases are converted to comma-separated cases.\n\n**Typescript**\n\n```typescript\nswitch (value) {\n    case 1:\n    case 2:\n        console.log('value is 1 or 2');\n        break;\n    case 3:\n        console.log('value is 3');\n        break;\n    default:\n        console.log('value is '+value);\n}\n```\n\n**Haxe**\n\n```haxe\nswitch (value) {\n    case 1, 2:\n        trace('value is 1 or 2');\n    case 3:\n        trace('value is 3');\n    default:\n        trace('value is ' + value);\n}\n```\n\n### Interfaces\n\n**Typescript**\n\n```typescript\ninterface MyInterface {\n    x:number;\n    y:number;\n    foo():void;\n}\n```\n\n**Haxe**\n\n```haxe\ninterface MyInterface {\n    public var x:Float;\n    public var y:Float;\n    public function foo():Void;\n}\n```\n\n### Classes\n\nClasses are properly converted, including typescript-specific features like getters/setters or properties in constructor signature.\n\n**Typescript**\n\n```typescript\nclass FooClass extends BarClass, BazClass implements QuxInterface {\n\n    private prop1:number;\n    static prop2:number = 0;\n\n    constructor(public prop3:number) {\n        this.prop1 = 0;\n    }\n\n    get prop4():number {\n        return this.prop1 + FooClass.prop2;\n    }\n\n    set prop4(value:number) {\n        this.prop1 = value - FooClass.prop3;\n    }\n\n}\n```\n\n**Haxe**\n\n```haxe\nclass FooClass extends BarClass extends BazClass implements QuxInterface {\n\n    private var prop1:Float;\n\n    static public var prop2:Float = 0;\n\n    public var prop3:Float;\n\n    public function new(prop3:Float) {\n        this.prop3 = prop3;\n        this.prop1 = 0;\n    }\n\n    public var prop4(get, set):Float;\n\n    public function get_prop4():Float {\n        return this.prop1 + FooClass.prop2;\n    }\n\n    public function set_prop4(value:Float):Float {\n        this.prop1 = value - FooClass.prop3;\n        return value;\n    }\n\n}\n```\n\n### Generics\n\nTypescript generics are converted to haxe generics. The ``@:generic`` macro is added automatically in haxe code.\n\n**Typescript**\n\n```typescript\nclass GenericClassExample<T> {\n\n    constructor(content:T) {\n    }\n    \n}\n\nclass GenericClassExample2<T extends InterfaceA> {\n\n    constructor(private content:T) {\n    }\n}\n```\n\n**Haxe**\n\n```haxe\n@:generic\nclass GenericClassExample<T> {\n\n    public function new(content:T) {\n    }\n\n}\n\n@:generic\nclass GenericClassExample2<T:InterfaceA> {\n\n    private var content:T;\n\n    public function new(content:T) {\n        this.content = content;\n    }\n\n}\n```\n\n### Closures\n\nTypescript's double-arrow closures are converted to Haxe, ensuring ``this`` is still referencing the parent context.\n\n**Typescript**\n\n```typescript\nclass Foo {\n\n    public name:string = 'Foo';\n\n    constructor() {\n\n        var someClosure = () => {\n            this.name += ' Bar';\n        }\n\n    }\n}\n```\n\n**Haxe**\n\n```haxe\nclass Foo {\n\n    public var name:String = 'Foo';\n\n    public function new() {\n        var __this = this;\n        var someClosure = function() {\n            __this.name += ' Bar';\n        }\n    }\n\n}\n```\n\n### Logs\n\n``console.log`` becomes ``trace``\n\n**Typescript**\n\n```typescript\nconsole.log('hello');\n```\n\n**Haxe**\n\n```haxe\ntrace('hello');\n```\n\n### setTimeout/setInterval\n\n``setTimeout`` and ``setInterval`` are converted to ``Ts2Hx.setTimeout`` and ``Ts2Hx.setInterval`` (requires **Ts2Hx.hx** support file).\n\n**Typescript**\n\n```typescript\nsetTimeout(function() {}, 1000);\nsetInterval(function() {}, 1000);\n```\n\n**Haxe**\n\n```haxe\nTs2Hx.setTimeout(function() {}, 1000);\nTs2Hx.setInterval(function() {}, 1000);\n```\n\n### Objects\n\nTypescript objects are converted to haxe anonymous structures. The ``delete`` keyword and brackets access are converted to their closest equivalent in haxe (requires **Ts2Hx.hx** support file).\n\n**Typescript**\n\n```typescript\nvar dict:any = {\n    foo: 'bar',\n    baz: 'qux'\n};\ndict['foo'] = 'baz';\ndict.baz = 1234;\ndict['foo' + dict.foo] = 'qux';\ndelete dict.baz;\n```\n\n**Haxe**\n\n```haxe\nvar dict:Dynamic = {\n    foo: 'bar',\n    baz: 'qux'\n};\ndict.foo = 'baz';\ndict.baz = 1234;\nTs2Hx.setValue(dict, 'foo' + dict.foo, 'qux');\nReflect.deleteField(dict, 'baz');\n```\n\n### For loops with incrementor\n\n``for`` loops with incrementor don't exist in haxe. They are converted to ``while`` loops.\n\n**Typescript**\n\n```typescript\nfor (var i = 0, len = 12; i < len; i++) {\n    console.log(\"for iteration #\"+i);\n}\n```\n\n**Haxe**\n\n```haxe\nvar i:Int = 0, len:Int = 12;\nwhile (i < len) {\n    trace(\"for iteration #\" + i);\n    i++;\n}\n```\n\n### For loops over object\n\n``for`` loops can be used to iterate over an object's keys.\n\n**Typescript**\n\n```typescript\nfor (var key:string in someObject) {\n    console.log('key: ' + key);\n    console.log('value: ' + someObject[key]);\n}\n```\n\n**Haxe**\n\n```haxe\nfor (key in Reflect.fields(someObject)) {\n    trace('key: ' + key);\n    trace('value: ' + Ts2Hx.getValue(someObject, key));\n}\n```\n\n### Call of forEach method of an Array\n\n``Array.forEach`` are transpiled to the closed equivalent in haxe (requires **Ts2Hx.hx** support file).\n\n**Typescript**\n\n```typescript\n['item1', 'item2'].forEach(function(value) {\n    console.log(value);\n});\n```\n\n**Haxe**\n\n```haxe\nTs2Hx.forEach(['item1', 'item2'], function(value) {\n    trace(value);\n});\n```\n\n### JSON parsing and dumping\n\n``JSON.parse`` and ``JSON.stringify`` are transpiled to the closed equivalent in haxe (requires **Ts2Hx.hx** support file).\n\n**Typescript**\n\n```typescript\nvar jsonValue:any = JSON.parse('{\"a\":1, \"b\": [\"c\", \"d\", \"e\"]}');\nvar jsonString:string = JSON.stringify(jsonValue);\n```\n\n**Haxe**\n\n```haxe\nvar jsonValue:Dynamic = Ts2Hx.JSONparse('{\"a\":1, \"b\": [\"c\", \"d\", \"e\"]}');\nvar jsonString:String = Ts2Hx.JSONstringify(jsonValue);\n```\n\n### More examples\n\nYou can find more examples in the ``examples/`` directory, such as ``try``/``catch``, ``do``/``while`` etc...\n\n\n","maintainers":[{"name":"jeremyfa","email":"contact@jeremyfa.com"}],"time":{"modified":"2022-06-27T22:24:55.680Z","created":"2014-11-15T15:10:17.151Z","1.0.0":"2014-11-15T15:10:17.151Z","1.0.1":"2014-11-15T15:12:14.624Z","1.0.2":"2014-11-15T15:23:53.532Z","1.1.0":"2014-11-16T23:00:17.698Z","1.1.1":"2014-11-30T15:03:15.556Z","1.1.2":"2014-12-02T07:31:37.627Z","1.1.3":"2014-12-02T07:35:51.552Z","1.1.4":"2014-12-03T01:05:05.918Z","1.1.5":"2014-12-13T22:38:47.332Z","1.1.6":"2015-01-01T21:18:52.829Z","1.1.7":"2015-01-02T09:39:57.586Z","1.1.8":"2015-01-04T21:42:34.266Z","1.1.9":"2015-01-21T13:05:58.715Z"},"author":{"name":"Jeremy Faivre","email":"contact@jeremyfa.com"},"license":"MIT","readmeFilename":"README.md","homepage":"https://github.com/jeremyfa/node-ts2hx","repository":{"type":"git","url":"git://github.com/jeremyfa/node-ts2hx.git"},"bugs":{"url":"https://github.com/jeremyfa/node-ts2hx/issues"}}