requirejs and "argument type exports.XXX is not assignable to parameter type XXX"

Hi all,

I've started to refactoring one of my projects to use requirejs. Now I get a lot of:

<code>argument type exports.XXX is not assignable to parameter type XXX</code>

For example, I have in 'geometry' module:

<code>
...
/**
* @constructor
*/
function Vector3() {...}

/**
* @param {Vector3} v1
* @param {Vector3} v2
*/
function createBox(v1, v2) {...}
...
</code>

and in another module:

<code>
...
geometry.createBox(new geometry.Vector3(-1, -1, -1), new geometry.Vector3(1, 1, 1));
...
</code>

The code works as it should but PhpStorm gives 2 warnings, both on the arguments in bold.

Is this a bug in PhpStorm or how do I supposed to document this the right way to make the warnings go away?

Thanks in advance for any insight,

Cornelis.

2 comments
Comment actions Permalink

Can you provide a full code snippet?
Note that WebStorm doesn't currently support documenting AMD modules. Some hints are suggested at http://blog.jetbrains.com/webstorm/2014/03/webstorm-8-rc/#comment-21822

0
Comment actions Permalink

Thanks for your reply.

The hints in the link are somewhat helpful, but I ended up prefixing all types with the module name. And then it can be imagined what happens when I like to test a module. For example replacing 'geometry' with 'geometry2'. Then all lights starts to blink again.

Besides that the overall code completion gets worst, most of the time code completion shows suggestions of totally unrelated fields of a object or no suggestions at all. And there seems to be no way to completely disable the built-in stubs (without modifying the jar's) so that I can use my own stubs without interfering.

I guess I have to wait untill requirejs is supported and hopefully the JavaScript code completion is by that time a lot better. For the time being I switch to 'Sublime Text' or so.

Anyway, thanks again for your reply.

0

Please sign in to leave a comment.