[英]Export module from TypeScript definition file
I am trying to create a definition file for the Vogels library. 我正在尝试为Vogels库创建一个定义文件。 This library wraps the AWS SDK, so it also includes a property that exports the entire AWS SDK.
该库包装了AWS开发工具包,因此它还包含一个导出整个AWS开发工具包的属性。
declare module "vogels" {
import AWS = require('aws-sdk');
export function define(modelName: String, config: any): void;
export var AWS: AWS; /* THIS LINE DOESN'T TRANSPILE */
}
This library is used like this: 该库的用法如下:
import vogels = require('vogels');
vogels.AWS.config.update({region: region});
var model = vogels.define('test', {
..
}
});
Unfortunately, exporting the AWS property from the "vogels" module doesn't work, because AWS is not considered a type. 不幸的是,由于“ AWS”不被视为类型,因此无法从“ vogels”模块导出AWS属性。 How can I export the AWS property without replicating the entire AWS definitions in my module?
如何在不复制模块中整个AWS定义的情况下导出AWS属性?
This seems to be the way to export the entire AWS module and the define
function: 这似乎是导出整个AWS模块和
define
函数的方法:
declare module "vogels" {
import AWS = require('aws-sdk');
function define(modelName: String, config: any): void;
export = { AWS, define }
}
You can only have a single export =
in a module, so all exported variables should be in that line (of course you can split it across multiple lines). 模块中只能有一个
export =
,因此所有导出的变量都应在该行中(当然,您可以将其拆分为多行)。 Don't export anything else, but only define interfaces, variables, ... The actual export is done later. 不要导出任何其他内容,而仅定义接口,变量等。实际导出将在以后完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.