Error with Property/Fields in typescript class
See original GitHub issueVersion
- Phaser Editor Version: Phaser Editor 2D - 2.1.6.20200120
- Operating system: windows 10
Description
I am quite new to the phaser environment, and I was testing Phaser editor with typescript. I have an issue with properties in scene class. If y use the button for assigning a property on an object in scene or declare a simple string as a class fields. The game load an empty scene at play and show an error in the browser console Uncaught SyntaxError: Unexpected identifier
I am sure that I miss something but I don’t understand why.
// You can write more code here
/* START OF COMPILED CODE */
class Scene1 extends Phaser.Scene {
constructor() {
super("Scene1");
}
_preload() {
this.load.pack("pack", "assets/pack.json");
}
_create() {
this.add.image(380.01807, 270.19016, "BG");
var fufu = this.add.image(414.1096, 257.46225, "fufu", 0);
this.fFufu = fufu;
}
private fFufu: Phaser.GameObjects.Image;
/* START-USER-CODE */
public str:string = "";
create() {
this._create();
}
/* END-USER-CODE */
}
/* END OF COMPILED CODE */

Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Looking for a reason the typescript class will not recognize ...
You are getting the following linting errors: Property 'text' has no initializer and is not definitely assigned in the constructor.
Read more >Property is missing in type 'X' but required in type 'Y' | bobbyhadz
The TypeScript error "Property is missing in type but required in type" occurs when we do not set all of the properties an...
Read more >Documentation - Classes - TypeScript
A field declaration creates a public writeable property on a class: ts. class Point {. x : number;. y : number;. } const...
Read more >Private properties make class instance types incompatible
The error message is quite clear and shows that this is intentional. The type you return must be assignable to the instance type,...
Read more >Private class features - JavaScript - MDN Web Docs - Mozilla
Class fields are public by default, but private class members can be ... It is also a syntax error to refer to private...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi,
Thank you for the response, it’s working great now. I thought that the phaser editor will directly compile ts into js.
Great.