title: Bad type annotation. Unknown type
body: <p>I keep getting the warning mentioned above but can't figure out why. I've added deps.js and deps.js contains a reference to the type.</p>
  
  <p>Here is the offending code:</p>
  
  <pre><code>goog.provide("MyCompany.MyApp.dom");
  
  
  MyCompany.MyApp.dom.getArticleAmountInput_=function(){
      return document.getElementById("articleAmount");
  };
  /**
   * Gets the article amount input value
   * @type {function(this:MyCompany.MyApp.dom):number} */
  MyCompany.MyApp.dom.getArticleAmount=function(){
      var tmp=this.getArticleAmountInput_();
      return (tmp)?tmp.value():undefined;
  };
  </code></pre>
  
  <p>In deps.js:</p>
  
  <pre><code>goog.addDependency('../../MyCompany/MyApp/dom.js', [ 'MyCompany.MyApp.dom'], []);
  </code></pre>
  
  <p>Code loads in html so it does find the class at runtime. Here is how I compile the code:</p>
  
  <pre><code>java -jar ../../compiler.jar \
  --compilation_level=ADVANCED_OPTIMIZATIONS \
  --formatting=PRETTY_PRINT \
  --warning_level=VERBOSE \
  --summary_detail_level=3 \
  --js=MyCompany/MyApp/dom.js \
  --js=closure/goog/deps.js \
  --js_output_file=out.js
  </code></pre>
  
  <p>And it keeps giving me the warning:</p>
  
  <blockquote>
    <p>WARNING - Bad type annotation. Unknown type MyCompany.MyApp.dom</p>
  </blockquote>
  
  <p><strong>[update]</strong></p>
  
  <p>Tried to leave out the <code>goog.provide</code> completely and leave out the <code>js=closure/goog/deps.js</code> when compiling and changed everything to lower case but keep getting the same warning on this code:</p>
  
  <pre><code>//goog.provide("mycompany.myapp.dom");
  var mycompany={};
  mycompany.myapp={};
  mycompany.myapp.dom={};
  
  mycompany.myapp.dom.getArticleAmountInput_=function(){
      return document.getElementById("articleAmount");
  };
  /**
   * Gets the article amount input value
   * @type {function(this:mycompany.myapp.dom):number} */
  mycompany.myapp.dom.getArticleAmount=function(){
      var tmp=this.getArticleAmountInput_();
      return (tmp)?tmp.value():undefined;
  };
  </code></pre>
  
  <p><strong>[update]</strong></p>
  
  <p>The thing is that when I add a typedef I get warnings that <code>myapp.dom is never defined</code> but when I let the code determine what the type is I get <code>Bad type annotation.</code></p>
  
  <p>Tried to add a typedef like so:</p>
  
  <pre><code>/**
   * @typedef {{getArticleAmount:function(this:myapp.dom):?number}}
   */
  myapp.dom;
  </code></pre>
  
  <p>But don't realy see why as <code>goog.provide</code> should create the myapp.dom and the compiler should know that.</p>
  
  <p><strong>[update]</strong></p>
  
  <p>I have created the following myapp.workflow from constructors. Now the compiler should recognize the type and Eclipse can code assist. Not sure if this is the way to do it but I'll try to re factor a small project.</p>
  
  <p>Setting up the main types in types.js</p>
  
  <pre><code>// source: js/mmyapp/types.js
  goog.provide("myapp.types");
  /** @constructor */
  var gooblediegoog=function(){};
  /** @constructor */
  gooblediegoog.prototype.WorkFlow=function(){};
  /** @constructor */
  gooblediegoog.prototype.Dom=function(){};
  myapp.types=new gooblediegoog();
  </code></pre>
  
  <p>A file that isn't used at all in my code but tells Eclipse how to auto complete:</p>
  
  <pre><code>// source: js/myapp/forCodeAssist.js
  /** @const {boolean} */
  var ALLWAYSFALSE=false;
  
  if(ALLWAYSFALSE){
      /**needed for Eclipse autocomplete
       * @constructor
       */
      var MyApp=function(){};
      MyApp.prototype.types=new gooblediegoog();
      Window.prototype.myapp=new MyApp();
      MyApp.prototype.workflow=new myapp.types.WorkFlow();
      MyApp.prototype.dom=new myapp.types.Dom();
  }
  </code></pre>
  
  <p>An implementation of workflow:</p>
  
  <pre><code>// source: js/myapp/workflow.js
  goog.provide("myapp.workflow");
  goog.require("myapp.types");
  goog.require("myapp.dom");
  
  /** @returns number|undefined */
  myapp.types.WorkFlow.prototype.createOrder=function(){
      return myapp.dom.getArticleAmout();
  };
  myapp.workflow=new myapp.types.WorkFlow();
  window['console'].log(myapp.workflow.createOrder());
  </code></pre>
  
  <p>This can be converted to a <code>myapp.workflow.createOrder=...</code> syntax by replacing <code>myapp.types.WorkFlow.prototype</code> with <code>myapp.workflow</code>, removing <code>myapp.workflow=new myapp.types.WorkFlow()</code> and removing the <code>goog.require("myapp.types")</code>. Maybe this can be automated in the build/compile process if needed.</p>
  
  <p>I am not sure if creating a single object with the help from a constructor function is much more expensive than just having <code>goog.require</code> create myapp.workflow and adding properties to it as I used to do (and as it's done in closure library).</p>