I’m working on a project involving WebGL, and using WebStorm to do the development.
One issue with the development flow is that WebStorm isn’t able to autocomplete things related to WebGL. In particular, if I annotate a value as being of type WebGLRenderingContext
/** @type {!WebGLRenderingContext} */
var gl;
WebStorm complains that WebGLRenderingContext is an unresolved variable. Also it complains about usages of methods on gl
, warning that it can’t find those methods so they may not exist.
My current workaround (besides just turning off the warnings) is to specify a record type like so:
* @type {{
* texParameteri: function,
* TEXTURE_WRAP_T: *,
* ...
* }}
var gl;
But obviously it’s a bit silly to be personally listing dozens and dozens of standardized members like this every time I want to use a rendering context. Is there an easier way?
5
you need to let WebStorm know about WebGL API. Just enable WebGL library in Settings | Languages & Frameworks | JavaScript | Libraries.
It will create/modify the file .idea/jsLibraryMappings.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="WebGL" />
</component>
</project>
See: http://blog.jetbrains.com/webstorm/2014/07/how-webstorm-works-completion-for-javascript-libraries/