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.
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.
Please sign in to leave a comment.
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
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:
'use strict';
var Model = require('models/ModelModule');
exports.foo = foo;
/**
*
* @param s {!string}
*/
function foo(s) {
}
});
Hi Bruce.
You could inline exports definition, i.e.
And I thought JSDoc will help here, but it doesn't:). I've created an issue, please watch it.
Thanks for the request!
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!