Description
When building on haxe 4 you'll get :
src/Api.hx:7: characters 8-25 : Type not found : haxe.web.Dispatch
src/Editor.hx:8: characters 8-17 : Type not found : js.JQuery
This is due to these haxe 4 changes :
all : moved haxe.web.Dispatch into hx3compat library (https://github.com/HaxeFoundation/hx3compat).
js : js.JQuery and js.SWFObject were moved into hx3compat library (https://github.com/HaxeFoundation/hx3compat)
1. Add hx3compat library
In the build.hxml
add -lib hx3compat
before and after --next
2. Adjust imports due to depreciation
There's a few changes in the source to adapt to the new syntax like changing all instances of :
-import js.JQuery;
+import js.jquery.JQuery;
3. Typing of events :
Change all instances of
-(e : JqEvent)
+(e : js.jquery.Event)
4. The library array had some typing issues :
if( program.libs != null ){
for( lib in libs.find("input.lib") ){
- if( program.libs.has( lib.val() ) ){
- lib.attr("checked","checked");
+ if( program.libs.has( new JQuery(lib).val() ) ){
+ new JQuery(lib).attr("checked","checked");
}else{
- lib.removeAttr("checked");
+ new JQuery(lib).removeAttr("checked");
}
}
}
- libs.push(i.val());
+ libs.push(new JQuery(i).val());
5. Button methods
And I wasn't sure where the .button*
methods were defined, as they were missing now. These changes made buttons work for me :
-compileBtn.buttonLoading();
+untyped compileBtn.button('loading');
- new JQuery(".link-btn, .fullscreen-btn")
- .buttonReset()
+ untyped new JQuery(".link-btn, .fullscreen-btn")
+ .button('reset')
- compileBtn.buttonReset();
+ untyped compileBtn.button('reset');
Note : These are not optimal changes, just the ones that made try.haxe work with haxe 4 for me.