Linting issues (VS Code, JS)

I have an html file that imports Babylon and then another js file via script tags. In the second file I get errors:
image
Though I have loaded Babylon and when I test the HTML file, it works fine.

Anyway to resolve this?
I am using a separate Javascript file, not Typescript.

cc @RaananW

may I ask - what is core.js? is it our baylon.jhs umd package?

No, core.js is for the game, and it has the references to Babylon.

the babylon namespace is being populated if you use our UMD version. if you use some other method you will need to take care of referencing the babylon types correctly.
Sharing a reproduction or the project will help us help you

The project is available here: GitHub - dr-vortex/blankstorm: Blankstorm development
The updated changes are not available (I can push them around 4:0pm cst).

The only relevant differences are some classes (Entity, Ship, PlayerData, Planet, Star, …) are moved to core.js, and all Babylon classes are prefixed with the namespace BABYLON. In index.html, an extra line is added right after the socket.io import (at line 574): <script class=core src=core.js></script>

@RaananW
Correction to my eairler statement: The updated project is available at GitHub - dr-vortex/blankstorm at temp-babylon-lint

i didnt look at the whole project but are you sure its not a simple race condition of the script tag order?

meaning if core.js references the BABYLON global variable then obviously babylonjs needs to be loaded before the core.js

I’ll double check but I don’t believe so

@shaderbytes it’s not race condition. Scripts tags are placed one after another so they are being parsed and executed in that order

@Vortex you said that it’s only IDE issue.
You don’t use TS in your project, can you just suspend the error in your IDE (what IDE are you using?)

You can also try something like adding
// global BABYLON comment at the top of the file

Or adding .tsconfig file

But you don’t use TS yourself so I wouldn’t recommend that

Interesting…

My IDE is VS Code, which I mentioned in the initial post

Adding //global BABYLON does not appear to affect anything

After adding "javascript.validate.enable": false to my settings, all errors go away (I tried adding intentional syntax errors and that didn’t generate any errors which is NOT intended). Continuing to read the first Stack Overflow post, adding the other settings did not affect the errors at all.

After reading the jsconfig.json Reference, I tried adding an include path and changing the module system but night have worked.

I also tried the ESLint extension which removed all but syntax errors (which kind of works)

From this, is there a babylon .d.ts file I could use?

I downloaded your repository and I don’t have that error in the VS Code. It does look like it’s problem specific to your toolset. I can’t help you if I can’t reproduce the error on my machine.

1 Like