Using inspections with require.js

I can't seems to get the function argument checkers to work when I call into functions in require.js.

I think this used to work, but maybe that was when I was using a different module definition syntax.

I'm currently using this syntax:

define('models/Game', function (require, exports, module) {
    'use strict';

}

I have to use this syntax, becuase otherwise I can't get JSTestDriver to play nice with my modules.

In any case, WebStorm seems completely unable to check any calls between modules.
4 comments
Comment actions Permalink

Hi Bruce,

Do you mean IDE does not validate the agruments you put in? Could you please bring up complete example with source code (e.g. moduleA using moduleB etc)?

Thanks,
Kirill

0
Comment actions Permalink

Sure, here's a simple exmple I just coded up.

I put comments that tell what errors are detected and what aren't.

File1, src/models/ModelModule.js:


define('widgets/ModelModule', function (require, exports, module) {
    'use strict';
    var Widget = require('widgets/WidgetModule');

    Widget.fooz();       // unresolved function - which is correct. There is no fooz
    Widget.foo();       // no errors. foo exists, but it requires a string arg
    bar();              // invalid number of paramters. expected one. which is correct

    /**
     *
     * @param s {!string}
     */
    function bar(s) {

    }
});


File2, src/widgets/WidgetModule.js:

define('widgets/WidgetModule', function (require, exports, module) {
    'use strict';
    var Model = require('models/ModelModule');

    exports.foo = foo;

    /**
     *
     * @param s {!string}
     */
    function foo(s) {

    }
});
0
Comment actions Permalink

Hi Bruce.
You could inline exports definition, i.e.  

/** @param {!string} s */
exports.foo = function(s) {}


And I thought JSDoc will help here, but it doesn't:). I've created an issue, please watch it.

Thanks for the request!
0
Comment actions Permalink

This doesn't work with the syntax I'm using.

Your example is for this syntax:

exports.abc = function () {
}

But I'm using this syntax:

exports.abc = abc;

function abc () {
}

With the syntax I'm using I can't find any way to get it to work.

But thatn's for the suggestion!

0

Please sign in to leave a comment.