-
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Describe the bug
Fields declared in Haxe as public var type(default, null):String are incorrectly generated as public var in AS3/TS externs, instead of being accessible only via getter.
To Reproduce
Steps to reproduce the behavior:
- Run this Royale sample
package {
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.display.Sprite;
import openfl.ui.Keyboard;
import openfl.ui.Multitouch;
public class App extends Sprite {
public function App() {
super();
var bitmapData:BitmapData = new BitmapData(32,32,false,0xFF0000);
bitmapData.perlinNoise(2,2,2,2,true,false);
/* Every line below should produce read-only property errors */
bitmapData.width = 111;
bitmapData.height = 55;
parent = new Sprite();
Multitouch.maxTouchPoints = 99;
Keyboard.capsLock = true;
/* end */
addChild(new Bitmap(bitmapData));
trace(parent);
trace(Multitouch.maxTouchPoints);
trace(Keyboard.capsLock);
}
}
}- Observe that compilation succeeds instead of producing errors.
Expected behavior
Errors should be shown: Property _x_ is read-only.
OpenFL Targets
AS3 Royale, TypeScript
Additional context
I think the problem is here
openfl-js/scripts/AS3ExternsGenerator.hx
Line 445 in ebba70e
| var isAccessor = read == AccCall || write == AccCall || mustBeAccessor(classField.name, interfaces); |
openfl-js/scripts/TSExternsGenerator.hx
Line 493 in ebba70e
| var isAccessor = read == AccCall || write == AccCall || mustBeAccessor(classField.name, interfaces); |
I tried changing the line to:
var isAccessor = read == AccCall || write == AccCall || mustBeAccessor(classField.name, interfaces)
|| (read != write && (read == AccNormal || write == AccNormal));This seems fixes the issue, but then in ByteArray, length property is generated as getter instead of public var. I’m not sure why.

Metadata
Metadata
Assignees
Labels
No labels