How to call TypeScript functions out of the .ts files?

后端 未结 2 578
青春惊慌失措
青春惊慌失措 2021-01-28 23:09

I have a very simple program to learn how to work with TypeScript, I bundled all my .ts files using Browserify to make it possible to run inside the browser.

<
2条回答
  •  清歌不尽
    2021-01-28 23:37

    How to design API of my library in TypeScript? (any good resource)

    Really a build tool chain question. If you want to expose your library as a global the answer is dependent on your toolchain. I recommend using webpack. Here is a a sample config:

    module.exports = {
        /** Build from built js file */
        entry: {
          typestyle: './lib/index.js',
        },
        output: {
            filename: './umd/typestyle.js',
            libraryTarget: 'umd',
            /** The library name on window */
            library: 'typestyle'
        }
    };
    

    From the TypeStyle project.

提交回复
热议问题