[SOLVED] Property 'globals' does not exist message in code editor(2339)

Hi there

Under all my globals variables in the editor I now find a message saying:
Property ‘globals’ does not exist on type ‘Window & typof globalsThis’. (2339)

Global variables are very useful for me although I know that there are some downsides with cluttering and memory. But I personally like them.

Is there anything I should be concerned about with this message?

Here’s a link to a short demo:
https://launch.playcanvas.com/1286042
https://playcanvas.com/editor/code/857500?tabs=62047056,62049755

Thank you!

Since the Code Editor is not an IDE, it is unaware of anything happening in the other script files you have written, so based on its knowledge of what is generally attached to the window object, window.globals doesn’t exist and it is warning you. Assuming globals.js loads before mainScript.js, you shouldn’t have any problems on Launch or build, but the editor will still complain as it doesn’t know what you’re doing.

In short, no, it’s not a warning you should be concerned about as long as you manage your script loading order.

2 Likes

Thanks for the explanation eproasim

Yes, loading order is set correct and all is working as expected in my project.
I was only nervous if I’m doing anything weird with my code and maybe should be aware of some problems.

1 Like

No problem! I’m glad it’s all working for you!

1 Like