I am facing a lot of issues with the playcanvas vs code extension because it does not show errors until the parse the scripts and run the game. As in, the type checking, code suggestions, line completion suggestions dont work. I am not entirely sure if the problem is because of vs code or the playcanvas extension
one of such instances is the below image. isDrawing boolean in Initialize is commented, yet the isDrawing boolean in the Update does not show the red underline indicating error.
I’m a little confused by the example provided here. In this case, you commented out this.isDrawing = false, meaning that most likely this.isDrawing = undefined which is a falsy value.
In your update function you then check to see if this.isDrawing is truthy, which it wouldn’t be because it is presumably undefined, meaning that the call to draw the arrow would never be processed. Regarding the lint highlighting, since it’s just Javascript and not Typescript, would we expect to see an error here when we’re just checking for truthiness? As far as I can tell, by your description of the behavior, the script is acting as intended, and the IDE as well.
Could you confirm what version of the VSCode extension you are using? Also please submit a report through the command palette (Ctrl + P, PlayCanvas: Report Issue). I will be able to track your state and debug from there.
Im not too sure myself.
I come for Unity and Cocos and as far as scripting in VS code, the IDE shows me the errors that i make while i code. for example,
ctrl+click on a function would take to the function definition
unused variables are highlighted and a tool tip showing that the variable is unused
end of line syntax suggestions
the suggestion to add a ‘this.’ before an existing variables
right click → go to definition takes me the place where the variable/function was defined
i was expected these sort of features to work with javascript within vs code, and I think it does because it does work for Python, C# and Typescript.
I am using Visual Studio Code 1.120 and PlayCanvas VS code extension 1.10.4
Im pretty sure it must a setup issue on my side, but sure i will send the report.
I am using Visual Studio Code 1.120 and PlayCanvas VS code extension 1.10.4
This actually shows VS Code type checking is working. The warning:
'SoundManager' is possibly 'null'. ts(18047)
comes from VS Code’s JavaScript/TypeScript checker. It happens because pc.createScript() is typed as possibly returning null, for example if a script with that name already exists.
So this screenshot is not showing missing type checking, it is showing a real type-check warning.
The earlier this.isDrawing example is a different case. In JavaScript, reading a missing property is legal:
if (this.isDrawing) {
...
}
If it was never assigned, it is just undefined, not a syntax error.
One important limitation is that classic PlayCanvas scripts are not strictly type-safe. They rely on runtime patterns like pc.createScript(), prototype assignment, and editor-injected attributes. Stronger type safety is mainly prioritised for ESM scripts, where imports, exports, classes, and JSDoc/TypeScript tooling can be understood much more reliably by VS Code.
If you have an example of invalid JavaScript syntax that VS Code is not flagging, please share that exact snippet/screenshot.
thanks. i was exploring all options before migrating completely to ESM style scripting.
I was explaining the same to claude and it spat out a vs code extension that solves the exact issues mentioned above. So that has been solved, for now.