打字稿编译文件

打字稿编译文件

问题描述:

我编译我的课:打字稿编译文件

export class Test implements baseTest 

编译文件中有第一个字符串:

define(Object, ......,); 

我怎么编译withor只定义是这样的:

var Test = (function(){..})(); 
+0

我相信这是由您的tsconfig.json文件的'compilerOptions.module'属性定义的。它根据你选择的选项不同地编译你的模块。尝试将其设置为“CommonJS”。 [https://www.typescriptlang.org/docs/handbook/compiler-options.html] – mhodges

+0

它也可以与'compilerOptions.target'属性结合使用。尝试定位“ES5”。您可能需要使用不同的组合。 – mhodges

+0

仅用于class ||功能 –

删除export关键字。当你想要全局代码时,你正试图创建一个模块。