declare namespace moment {
...
}
export = moment;
这是从 Moment.js 库的 TypeScript 声明文件中引用的。最后一行是什么意思?这里的'export'关键字和Node.js中的'export'关键字一样吗?
最佳答案
这是 TypeScript 的 'export =' syntax 。来自文档:
The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
这不是标准的 ES6 JavaScript,如果在那里使用可能会引发语法错误。 TypeScript 转换导出的方式取决于它所处的模式:
Depending on the module target specified during compilation, the compiler will generate appropriate code for Node.js (CommonJS), require.js (AMD), isomorphic (UMD), SystemJS, or ECMAScript 2015 native modules (ES6) module-loading systems. For more information on what the define, require and register calls in the generated code do, consult the documentation for each module loader.
关于javascript - 在 TypeScript 中为 'export' 赋值意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40946908/