{"id":20406584,"url":"https://github.com/elsassph/hxtsdgen","last_synced_at":"2025-04-12T15:07:55.087Z","repository":{"id":137662784,"uuid":"82293172","full_name":"elsassph/hxtsdgen","owner":"elsassph","description":"TypeScript declaration file generator for Haxe JavaScript output target","archived":false,"fork":false,"pushed_at":"2022-11-23T07:47:00.000Z","size":85,"stargazers_count":66,"open_issues_count":15,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-12T15:07:52.606Z","etag":null,"topics":["haxe","interoperability","javascript","typescript"],"latest_commit_sha":null,"homepage":null,"language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elsassph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-17T12:00:11.000Z","updated_at":"2025-04-12T03:01:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa1646ae-721a-4a5c-b3fb-fc3321d2ead5","html_url":"https://github.com/elsassph/hxtsdgen","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsassph%2Fhxtsdgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsassph%2Fhxtsdgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsassph%2Fhxtsdgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsassph%2Fhxtsdgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elsassph","download_url":"https://codeload.github.com/elsassph/hxtsdgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586236,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haxe","interoperability","javascript","typescript"],"created_at":"2024-11-15T05:18:07.568Z","updated_at":"2025-04-12T15:07:55.078Z","avatar_url":"https://github.com/elsassph.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Declaration Generator for Haxe/JS\n\n[![Build Status](https://travis-ci.org/nadako/hxtsdgen.svg?branch=master)](https://travis-ci.org/nadako/hxtsdgen)\n\n**STATUS: WIP usable with limitations, feedback welcome!**\n\nThis is a [TypeScript declaration file](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)\ngenerator for the [Haxe](https://haxe.org/) JavaScript output target.\n\nWhat it does is generate a `.d.ts` file next to the `.js` file generated by Haxe compiler,\ncontaining TypeScript declarations for classes and functions exposed from Haxe using the\n[`@:expose` metadata](http://haxe.org/manual/target-javascript-expose.html), and all their\nrelated types (function arguments and return types).\n\n## Why?\n\nTo make using Haxe/JS modules from both JavaScript and TypeScript much easier, of course!\nJust compile your Haxe library to a JS module and use it in TypeScript in a perfectly typed way.\n\n## Usage\n\nJust add `-lib hxtsdgen` to compiler arguments and a `.d.ts` file will be produced along the normal JS output.\n\n## Options\n\n### Concrete enums export\n\nUsing compiler option `-D hxtsdgen_enums_ts`, the library will produce an extra `output-enums.ts`\nwith concrete TypeScript enums from Haxe Abstract Enums (see \"Limitations\").\n\nTo change the enums' file name, use `-D hxtsggen_enums_ts=other_name` to produce `other_name.ts`.\n\n### Separate types export\n\nUsing compiler option `-D hxtsdgen_types_ts`, the library will produce an extra `output-types.d.ts`\nwith all the interfaces and typedefs separated from the classes \u0026 functions declarations.\n\nTo change the types' file name, use `-D hxtsggen_types_ts=other_name` to produce `other_name.d.ts`.\n\n### Custom output header\n\nBy default, generated files include a comment warning that the file is generated.\n\n- Using compiler option `-D hxtsdgen_skip_header`, no header will be included.\n\n- Header can be overriden by adding the following compiler macro to your build:\n    ```\n    --macro hxtsdgen.Generator.setHeader('/* tslint:disable */')\n    ```\n\n\n## Supported Haxe features\n\nCertain Haxe features are compiler abstractions and thus may not be possible to translate\nto TypeScript.\n\n- [x] Classes\n- [x] Interfaces\n- [x] [Anonymous Structure](https://haxe.org/manual/types-anonymous-structure.html) Typedefs\n- [ ] Option to generate interfaces from Typedefs?\n- [ ] Other uses of [typedefs](https://haxe.org/manual/type-system-typedef.html)\n- [x] Properties (as `get_prop/set_prop`)\n- [ ] Native properties (needs compiler support)\n- [ ] Enums (needs compiler support)\n- [x] [Abstract enums](https://haxe.org/manual/types-abstract-enum.html) (see limitations)\n- [x] Abstract enums as concrete `.ts` enums (`-D hxtsdgen_enums_ts`)\n- [ ] Option to generate \"fat enums\" from Abstract enums?\n- [ ] More general [abstracts](https://haxe.org/manual/types-abstract.html) (unlikely, excepted possibly for return values)\n\n### Haxe packages\n\nBy default, Haxe packages are flattened.\n\nE.g. `com.foo.Thing` in Haxe can be imported as:\n\n```typescript\nimport { com_foo_Thing } from './thing';\nconst thing = new com_foo_Thing();\n```\n\nYou can use `@:expose('FriendlyName')`, which will export\nmodule-level declarations:\n\n```haxe\npackage com.foo;\n\n@:expose('Thing')\nclass Thing {...}\n```\n\nCan be (nicely) imported as:\n\n```typescript\nimport { Thing } from './thing';\nconst thing = new Thing();\n```\n\nTo prevent flattening, set `-D hxtsdgen_namespaced`, but it doesn't play well with\n`hxtsdgen_enums_ts` and `hxtsdgen_types_ts`...\n\n### Limitations\n\n#### No automatic export\n\nCurrently all the types have to be explicitly exposed; types used by functions won't be\nautomatically exported so everything must be currently annotated for export.\n\n#### Abstract enums\n\n`hxtsdgen` can generate TypeScript [const enums](https://www.typescriptlang.org/docs/handbook/enums.html),\nwhich are a pure compiler construction, substituted at compile time with their value.\n\nHowever `.ts` code can be compiled by 2 compilers: TypeScript and Babel.\n\n- Check Babel's `const enum` support: https://github.com/babel/babel/issues/8741\n- TypeScript supports `const enum` in `.d.ts` files only in full compilations.\n\nFor optimal compiler compatibility, add `-D hxtsdgen_enums_ts` to hint hxtsdgen to\ngenerate enums in a separate `.ts` file which will be compatible with\n`--transpileOnly --preserveConstEnums`.\n\n#### Abstracts and (regular) Enums\n\nEnums and Abstracts are a key feature of the Haxe language, but They don't translate well\nto JavaScript APIs as they are a compiler feature.\n\nGeneral Abstracts, offering compile-time types abstractions and operators overloading will\nprobably never be supported.\n\nEnums could be somehow supported, but currently the compiler doesn't allow exposing them.\n\n#### Native properties\n\nHaxe JS doesn't generate native properties in any language - they are always transformed\ninto `get_prop/set_prop` functions. It is possible that in the future the Haxe compiler\nwill allow exporting native properties.\n\n\n## How does it look?\n\nCheck out these 3 awesome panes (left-to-right):\n\n * `Main.hx` (Haxe source code)\n * `main.d.ts` (generated TypeScript declarations)\n * `test.ts` (TypeScript source code that uses the declarations)\n\n![](http://i.imgur.com/AHmdHtv.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsassph%2Fhxtsdgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felsassph%2Fhxtsdgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsassph%2Fhxtsdgen/lists"}