Engine Release: v1.26.0

Urm, Will, i think you missed my issue I have with the latest build and now the online editor has the similar problem as well. attributes typehinting is lost on generated class, and for es5 case, this.attributes is erraneously reflected as a typehint, when in reality it should be undefined .This problem wasn’t addressed?

https://github.com/playcanvas/engine/pull/1908#issuecomment-603175894

I have to manually patch the playcanvas.d.ts file to add an actual static behind readonly attributes, so it doesn’t appear as a member instance property but instead reflects the proper typehint for ScriptTypeClass.attributes… Somehow, when using jsdoc to export out the field definition (@static) keyword gets reflected, but it appears to have no effect on the typehints compared to a full static declaration.

Regarding Typescript and “the outdated template”…

Use my updated one that is more fairly recent Introducing updated Playcanvas JS/Typescript Template . I have working recent Typescript template examples for the version of Playcanvas just before this new 1.26.0 update (backward compatible) which should still work despite not using the new 1.26.0 version approach (that now allows extending pc.ScriptType directly), . Looks like on the new roadmap, I’d have to change the approach to extending pc.ScriptType directly and using a a possibly new @registerScript decorator instead (rather than the current @createScript decorator) . However, i think i’d hold this back until the inherant issues with failure to recognise/parse scripts within online editor is dealt with with regards to extending pc.ScriptType directly. (including the typehinting attributes issue i mentioned above).

Honestly though, i felt this update wasn’t really that “perfect” (and i thought you’d would had tested this for longer). There are already some issues assosiated with the use of Es6 classes as mentioned by the others. However, it’s one of those features i won’t use directly anyway since i also want to support mobile browsers as well, which means Babel or some means of transpiling (like Typescript), is still needed just in case (possible to do for online editor compile?).

At least it’s a first step, but ideally, I would have wished for the ability to extend pc.ScriptType directly without having to remember to use “registerScript” at the bottom. (eg. like how in React, you can extend React.Component directly…). Unfortunately, given the way Playcanvas works, this might not be possible without the use of decorators to make the process more obvious( declaring it on top so it stands out more…). But decorators are non-standard browser feature requiring either Babel/Typescript. Also, I would wish to have the ability to locally define typed attributes with full type hinting/type checking support available within Typescript like what i already have in my Babel/Typescript template, (but again, i use decorators for this…).

1 Like