title: TS typings: How to access to namespace inside module?
body: <p>While using Typescript at work I encountered many dependencies that doesn't have the typings, both in project or in @types on NPM. While for some I was able to create on my own, in the case of youbora (<a href="https://bitbucket.org/npaw/lib-plugin-js/src/49d610d64198/src/?at=master" rel="nofollow noreferrer">here is the public source code @ bitbucket</a>), a QA library for video players, I cannot create them: particularly I get stuck with namespaces.</p>
  
  <p>Youbora let the developer to use it by creating a Plugin and registering an adapter.</p>
  
  <pre class="lang-js prettyprint-override"><code>import * as youbora from "youboralib";
  import "youbora-adapter-shaka";
  
  // ---- in my classes ----
  
  this.youbora = new youbora.Plugin({ ... });
  </code></pre>
  
  <p>In another class/component (we are using react with typescript):</p>
  
  <pre class="lang-js prettyprint-override"><code>this.props.youbora.setAdapter(
      new youbora.adapters.Shaka(document.getElementById("videoContent"))
  );
  </code></pre>
  
  <p>Typescript tells me that "youboralib" (which is the package name on NPM) has no declarations files. So I created it looking at the source code.</p>
  
  <pre class="lang-js prettyprint-override"><code>declare module "youboralib" {
    class Plugin {
      constructor(options: YouboraNS.PluginOpts, adapter?: YouboraNS.Adapter);
      setAdapter(adapter: YouboraNS.Adapter): void
      // ...
    }
  
    namespace adapters {}
  
    namespace YouboraNS {
      interface PluginOpts {}
      interface Adapter {
        plugin: any
      }
      interface Communication {}
    }
  }
  </code></pre>
  
  <p>As we only include Plugin class, there are no problems.</p>
  
  <p><code>Youbora.adapters</code>, per the source code, is an empty object that gets populated by the imported adapters (like above, <code>youbora-adapter-shaka</code>). So it is possible to do, as above, <code>new youbora.adapters.Shaka(...)</code>.</p>
  
  <p>In terms on typings, it should be a namespace (as written).
  The problem is that if I declare a namespace in the module, I cannot access to it from the outside but only from the inside (as YouboraNS): in fact, VSCode suggests me only <code>Plugin</code> class. I made different searches across the web and SO but got no results.</p>
  
  <p>So the problem here is: how can I access to a module-specific namespace?</p>
  
  <p>To bypass this problem, I had to disable the flag <code>tsconfig.CompilerOptions.noImplicitAny</code> and / or use <code>@ts-ignore</code> above the instructions, but they are a so ugly solutions.</p>
  
  <p>========================</p>
  
  <p>If you look at <a href="https://bitbucket.org/npaw/lib-plugin-js/src/49d610d64198fc0bd549c82166c373b51a48cf69/src/youboralib.js" rel="nofollow noreferrer">the code of <code>youboralib.js</code></a>, you can see that actually "youbora" can be considered as a namespace itself, as it is an object with different properties.</p>
  
  <p>So I tried to define it as a namespace, but still VSCode doesn't recognize it as a module:</p>
  
  <pre class="lang-js prettyprint-override"><code>export = youboralib;
  export as namespace youboralib;
  
  declare namespace youboralib {
    class Plugin { ... }
    namespace adapters {}
  }
  </code></pre>
  
  <p>I tried also with <code>export namespace adapters {}</code> or something like this but got nothing different.</p>
  
  <p>Any ideas? Thank you.</p>