Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods assigned to exports get "Unresolved function or method" warning #69

Open
AllieCR opened this issue Nov 8, 2017 · 0 comments
Open

Comments

@AllieCR
Copy link

AllieCR commented Nov 8, 2017

Description

If you use requireJS in the CommonJS style and add a method the exports parameter it provides, Webstorm will not be able to resolve that method if you attempt to use it elsewhere. However, this problem does not occur if you use module.exports instead of just exports.

Example

// JustExports.js
define(function(require, exports) {
  exports.someMethod = function() {};
});

// ModuleDotExports.js
define(function(require, exports, module) {
  module.exports.someMethod = function() {};
});

// UseExports.js
define(function(require) {
  var JustExports = require('JustExports');
  var ModuleDotExports = require('ModuleDotExports');

  // If you mouse over `someMethod` here, Webstorm shows the warning 
  // "Unresolved function or method someMethod()"
  JustExports.someMethod();

  // If you hold down the Cmd key and mouse over `someMethod` here, Webstorm turns the
  // cursor into a pointer and tells you where the method lives. If you click on it,
  // Webstorm will take you to the method definition.
  ModuleDotExports.someMethod();
});

Example from real life project

image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant