title: TypeScript use dynamic import in ES5 with Bluebird
body: <p>I'm trying to use the new dynamic <code>import()</code> function in TypeScript, but I get the following error:</p>
  
  <blockquote>
    <p><strong>TS2712:</strong> A dynamic import call in ES5/ES3 requires the 'Promise'
    constructor.  Make sure you have a declaration for the 'Promise'
    constructor or include 'ES2015' in your <code>--lib</code> option.</p>
  </blockquote>
  
  <p>I could include the <code>ES2015.promise</code> lib in my tsconfig like the message suggests, but that would make me lose type safety as I'm using Bluebird promises.</p>
  
  <p>I know it is possible to use Bluebird for <code>async/await</code> in TypeScript, so I suppose this should also work the same way.</p>
  
  <hr>
  
  <p><strong>The message also mentions this:</strong></p>
  
  <blockquote>
    <p>Make sure you have a declaration for the 'Promise' constructor or [...]</p>
  </blockquote>
  
  <p>Is it possible to declare the Bluebird constructor to be used as the Promise constructor in TS?</p>
  
  <hr>
  
  <p><em>Example code:</em></p>
  
  <pre><code>import * as Bluebird from 'bluebird';
  
  // This works
  async function exampleAsync(): Bluebird&lt;number&gt; {
      const result = await Bluebird.resolve(5);
      return result;
  }
  
  // This does not
  import('jquery').then($ =&gt; {
      console.log($.fn.jquery);
  });
  </code></pre>
  
  <p><em>TSConfig:</em></p>
  
  <pre><code>{
    "compilerOptions": {
      "module": "commonjs",
      "target": "es5",
      "removeComments": true,
      "sourceMap": true,
      "alwaysStrict": true,
      "forceConsistentCasingInFileNames": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "strictNullChecks": true,
      "allowJs": true,
      "typeRoots": ["node_modules/@types"],
      "lib": ["es5", "dom", "es2015.collection"]
    },
    "exclude": ["node_modules"]
  }
  </code></pre>