thanks that clears up bunch of my code from Object.assign statement
i find these static type checker to be very useful to cleanly code and navigate through them.
is there any workaround with these static type checker complain ?
or is it just straight better to migrate to typescript instead ?
I too was used to C# when starting with Phaser and after struggling with javascript for a while I changed to typescript and felt right at home. You might find this to be the case for you as well! (In addition, next major release of Phaser is developed using typescript)
thanks a lot.this does looks nice and easily implemented.
my friend do provide similar but different approach like these. but i believe yours are way better since his are creating inheritance with additional handling which add additional complexity when using it.
but naming would turn quite weird. since most of my stuff is extending functionality of phaser component. like SizeExtension, TransformExtension, group extension. and it only have small code snippet to utilize when needed.
so i’ve tried what the article told me. and it does work like c# extension method.
but i got concerned since this is javascript which doesn’t compile.
it got me thinking that everytime i call extension scripts every property assignment are done repeatedly. does this will affect performance in the long run when those extension script are going to be called in many scripts where extension method are going to be required. and missing it would result in an error.
does typescript compilation help with this ? as of converting multiple extension script call into 1 call.
i’m still on migration process to typescript and so far what i felt is more organized code
but those prototype extension will have global scope. and that’s the what i’m concerned with.
what if there are case where another developer might add same property as what i already did. and it gets overwritten and mess with many functionality related to it.