0

How to solve this error?

===plugin.js

(function($) {
   $.fn.myjqueryplugin = function(options) {};

   $.fn.func1 = function() {
      return this;
   };
}(jQuery));

===base.js

$(document).ready(function() {
    my_plugin = $("#myid").myjqueryplugin();
});

===hello.js

$(document).ready(function() {
  my_plugin.func1();
});

===BUILD file

Properly define 3 js files with correct order.

Closure compiler error on hello.js

[JSC_POSSIBLE_INEXISTENT_PROPERTY] Property func1 never defined on *

How Closure compiler is able to find 'func1'?

user6101147
  • 185
  • 1
  • 3
  • 14
  • You should look into defining an extern file for the plugin. See the documentation, and other stack overflow questions, https://developers.google.com/closure/compiler/docs/api-tutorial3#externs – Graham P Heath Jul 18 '19 at 15:53
  • Appreciate your reply. If possible, can you give more specific sample? – user6101147 Jul 18 '19 at 16:37
  • How about these links? https://blogs.missouristate.edu/web/2011/02/14/jquery-plugins-and-closure-compiler/ or https://stackoverflow.com/questions/21122259/creating-closure-compiler-extern – Graham P Heath Jul 18 '19 at 20:04
  • Still not able to figure out what/how to do to get rid of the error, even reading the doc recommended. Someone could help? Thank you. – user6101147 Jul 26 '19 at 18:12

0 Answers0