question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with Property/Fields in typescript class

See original GitHub issue

Version

  • 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 */

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ArnaudDroxlercommented, Apr 27, 2020

Hi,

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

0reactions
PhaserEditor2Dcommented, Apr 27, 2020

Great.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found