# Support for typescript extern file and split file for class

**URL:** https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222
**Category:** Haxe
**Tags:** haxe-js, typescript
**Created:** [January 18, 2020, 3:18pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222 "2020-01-18T15:18:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![francescoagati](https://community.haxe.org/user_avatar/community.haxe.org/francescoagati/32/503_2.png) [@francescoagati](https://community.haxe.org/u/francescoagati)
#### Post date: [January 18, 2020, 3:18pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/1 "2020-01-18T15:18:38Z")

</div>

Hi,  
There Is a roaadmap for supporto export import class in es6 with file split for classe. And and idea for a new target that emit code with file .d.ts?

---

<div class="post-metadata">

### Author: ![nanjizal](https://community.haxe.org/user_avatar/community.haxe.org/nanjizal/32/239_2.png) [@nanjizal](https://community.haxe.org/u/nanjizal)
#### Post date: [January 18, 2020, 6:02pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/2 "2020-01-18T18:02:02Z")

</div>

I believe there is support for es6 since haxe 4.0.5 development.  
-D js-es=6  
([https://github.com/HaxeFoundation/haxe/commit/406d3fb2bfb4016b384082768182a3d470633ed8](https://github.com/HaxeFoundation/haxe/commit/406d3fb2bfb4016b384082768182a3d470633ed8) )  
Support for ts is via haxelib.  
[https://github.com/elsassph/hxtsdgen](https://github.com/elsassph/hxtsdgen)  
Pretty sure these are not perfect but I thought that OpenFL uses them to provide wider support, although they may manually also patch.  
I don’t think there is any timescale attached they will mature with every new pull, but they are probably quite usable given some care?

---

<div class="post-metadata">

### Author: ![francescoagati](https://community.haxe.org/user_avatar/community.haxe.org/francescoagati/32/503_2.png) [@francescoagati](https://community.haxe.org/u/francescoagati)
#### Post date: [January 20, 2020, 12:53pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/3 "2020-01-20T12:53:12Z")

</div>

yes but with big code split of a file for each class can be slow in haxe and should be made in ocaml direclty

---

<div class="post-metadata">

### Author: ![benmerckx](https://community.haxe.org/user_avatar/community.haxe.org/benmerckx/32/906_2.png) [@benmerckx](https://community.haxe.org/u/benmerckx)
#### Post date: [January 20, 2020, 5:21pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/4 "2020-01-20T17:21:48Z")

</div>

I was hoping to eventually see this in Haxe but the issue tracking this was unfortunately closed recently: [JS Code Splitting / Reloading · Issue #5831 · HaxeFoundation/haxe · GitHub](https://github.com/HaxeFoundation/haxe/issues/5831)  
I experimented doing this in a custom generator:  
[GitHub - benmerckx/genes: Generates split ES6 modules and Typescript definitions from Haxe modules.](https://github.com/benmerckx/genes)  
There’s also hxgenjs which has been around longer, although the typings are more basic (defaulting to “any”):  
[GitHub - kevinresol/hxgenjs: Extensible JS generator for Haxe](https://github.com/kevinresol/hxgenjs)  
If it doesn’t find its way into the Haxe compiler you could go all the way and implement it as a compiler plugin.

---

<div class="post-metadata">

### Author: ![francescoagati](https://community.haxe.org/user_avatar/community.haxe.org/francescoagati/32/503_2.png) [@francescoagati](https://community.haxe.org/u/francescoagati)
#### Post date: [January 27, 2020, 4:23pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/5 "2020-01-27T16:23:44Z")

</div>

i think that a merge of hxgenjs an hxtsgen can resolve the problem for the typing. but the problem are the performance. if the cache compiler can pass to an api only the files that are change should be possible regenerate only the file js that are changed with the corrispective classes haxe

---

<div class="post-metadata">

### Author: ![benmerckx](https://community.haxe.org/user_avatar/community.haxe.org/benmerckx/32/906_2.png) [@benmerckx](https://community.haxe.org/u/benmerckx)
#### Post date: [January 28, 2020, 6:44pm UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/6 "2020-01-28T18:44:41Z")

</div>

In genes I managed to only recompile files when needed if you’re using a completion server. Full compile:  
 ![image](https://community.haxe.org/uploads/default/original/2X/7/7f6f7c89df4ccd505da3b889868d92ad8ffa1cfc.png)  
Recompilation:  
 ![image](https://community.haxe.org/uploads/default/original/2X/1/19ad2d78eebe6b9c91b91f722d94e19df53dfa85.png)

---

<div class="post-metadata">

### Author: ![francescoagati](https://community.haxe.org/user_avatar/community.haxe.org/francescoagati/32/503_2.png) [@francescoagati](https://community.haxe.org/u/francescoagati)
#### Post date: [January 29, 2020, 10:39am UTC](https://community.haxe.org/t/support-for-typescript-extern-file-and-split-file-for-class/2222/7 "2020-01-29T10:39:08Z")

</div>

But in your project you do also the split of js files for class?
