title: (TypeScript) Creating type definition for Parse SDK (Browser and Node)
body: <p>I'm creating a Typescript type definition for the <a href="http://www.parse.com/docs/js/" rel="noreferrer">Parse Javascript SDK</a>. It's actually complete. The definition would work for the Browse and Cloud Code but not in Node.</p>
  
  <p><strong>Using Parse with both client side and server side javascript</strong></p>
  
  <p><strong>Browse Example:</strong></p>
  
  <pre><code>var GameScore = Parse.Object.extend("GameScore");
  </code></pre>
  
  <p><strong>Node Example:</strong></p>
  
  <pre><code>var Parse = require('parse').Parse;
  var GameScore = Parse.Object.extend("GameScore"); 
  </code></pre>
  
  <p><strong>Psuedue Type Definition</strong></p>
  
  <pre><code>declare module Parse {
  
      interface FacebookUtils {
          init(options?: any);
      }
  
      class Object {
          constructor(attributes?: any, options?: any);
  
      }
  
      module Cloud {
  
          interface FunctionResponse {
              success?: (response: HttpResponse) =&gt; void;
              error?: (response: HttpResponse) =&gt; void;
          }
      }
  
  }
  
  declare module "parse" {
      export = Parse;
  }
  </code></pre>
  
  <p><strong>Using Parse with newly create definition</strong></p>
  
  <pre><code>class GameScore extends Parse.Object {}
  
  var gameScore = new GameScore();
  </code></pre>
  
  <p>Everything would work fine in the <b>Browse</b> because the Parse library is globally available.</p>
  
  <p>Now in <b>Node</b> everything would work fine if the import were like this:</p>
  
  <pre><code>var Parse = require("parse"); 
  </code></pre>
  
  <p>But the import is actually like this:</p>
  
  <pre><code>var Parse = require("parse").Parse;
  </code></pre>
  
  <p>So the <b>".Parse"</b> at the end of the import would cause a problem when trying to access <b>Parse.Object</b> because there is no accessor for ".Parse" in the definition above.</p>
  
  <p>So what I want to do is have a single definition file that works for both Browser and Node. I thought about using an interface but I don't think that would allow me to do extends or implements when I want to.</p>
  
  <p><b>For example:</b></p>
  
  <pre><code>declare module Parse {
  
      ...
  
      interface Parse {
          Object: Object;
      }
  }
  
  declare module "parse" {
          export = Parse;
  }
  </code></pre>
  
  <p>This wouldn't allow me to extend <b>Object</b>, it's just defined as a property in the Parse interface.</p>
  
  <p>Any help would be great. Thanks.</p>