Open AdrianV opened 1 year ago
I have this little example that compiles fine under Haxe 4.2.5 or less. With Haxe 4.3.1 it complains with:
"expression should be a field or of type State (found Int)" - for model.value in <ValStepper value={model.value} step={model.step} />
model.value
<ValStepper value={model.value} step={model.step} />
#if !macro import coconut.data.*; import coconut.ui.*; import coconut.Ui.hxx; import coco.*; import tink.domspec.*; import haxe.DynamicAccess; import js.html.*; #else import haxe.macro.Context; import haxe.macro.Expr; using tink.MacroApi; #end using tink.CoreApi; import js.Browser.document; import tink.state.Scheduler; class ValStepper extends coconut.ui.View { @:attribute var step:Int = 1; @:controlled var value:Int; function render() <div class="counter"> <button onclick={value -= step}>-</button> <span>{value}</span> <button onclick={value += step}>+</button> </div> ; } class TestModel implements Model { @:observable var step: Int = 5; @:editable var value: Int = 0; @:transition function setStep(v) { return {step: v}; } } class TestView1 extends coconut.ui.View { @:attribute var model: TestModel; function render() { return <> <div> <ValStepper value={model.value} step={model.step} /> </div> <div>{model.value}</div> </>; } } class Main { static var model = new TestModel(); static function main() { Renderer.mount(document.getElementById('app'), hxx(<TestView1 model={model} />)); model.setStep(2); } }
-cp src -D analyzer-optimize -main Main --js bin/test.js --library coconut.vdom --library coconut.ui --library coconut.data --dce full
<body> <div id="app"> </div> <script src="test.js" /> </body>
I have this little example that compiles fine under Haxe 4.2.5 or less. With Haxe 4.3.1 it complains with:
"expression should be a field or of type State (found Int)" - for
model.value
in<ValStepper value={model.value} step={model.step} />
Main.hx
build.hxml
index.html