Red warning dots in the editor for global js libraries


#1

Hey there! I’m doing some google maps stuff in Glitch at the moment and have a very minor question I thought was just about worth asking here. Because of the old-school way the Google Maps API is loaded via a script tag, there’s no require() or import() in the code and so Glitch marks every API call with a red warning dot.

I was wondering: is there some kind of nice way around this? Like maybe some Glitch feature I’m not aware of, or even a little JS syntax trick that gets rid of the dots? The best one I’ve found so far is accessing everything via window.google.maps instead of just google.maps. Anybody got anything different they’d suggest?


#2

Hello there @hen!

In the glitch editor, when you see red dots like this, that means that there is an error on that line, or there is something that is undefined, in the image I can see that you do not have google defined in that file of your project!


#3

Hey @hen you can also use a per-file eslint directive to set your google object as a recognized global:

/* global google */

That should rid your file of those pesky red dots for google refs.

Happy Glitching!