Accessing WebPacked TypeScript from Javascript

Accessing WebPacked TypeScript from Javascript

While I was trying to incorporate Stripe’s Javascript library into my codebase, I ran into some issues implementing it in Typescript. I eventually was able to fix those issues, but while I was trying to figure that out, I left the Stripe code as Javascript and stumbled upon an interesting way to interface that with my Typescript code compiled by WebPack.

First, at the bottom of the Typescript file you want to call from Javascript:

module.exports = {
    methodName: methodName,

In webpack.common.js:

  output: {
    library: 'MyExposedNamespace'

Finally, in the Javascript file: