[英]How do I use AWS sdk definitions for TypeScript?
I am trying to write an SES TypeScript client, using AWS definitions file downloaded from https://github.com/borisyankov/DefinitelyTyped/blob/master/aws-sdk/aws-sdk.d.ts 我正在尝试使用从https://github.com/borisyankov/DefinitelyTyped/blob/master/aws-sdk/aws-sdk.d.ts下载的AWS定义文件编写SES TypeScript客户端
Here is what I've tried: 这是我尝试过的:
/// <reference path="../typings/aws-sdk.d.ts" />
var AWS = require('aws-sdk');
var ses:SES = new AWS.SES();
Here is the error that I get: 这是我得到的错误:
/usr/local/bin/tsc --sourcemap SesTest.ts
SesTest.ts(3,9): error TS2304: Cannot find name 'SES'.
Process finished with exit code 2
I cannot find any documentation on how to make this work. 我找不到任何关于如何使这项工作的文件。 Please help!
请帮忙!
I think a more appropriate way to do this is 我认为更合适的方法是这样做
import { <ServiceName> } from 'aws-sdk';
for instance 例如
import { DynamoDB } from 'aws-sdk';
followed by 其次是
this.client = new DynamoDB();
in the class. 在课堂里。
I say it is more appropriate because it uses TypeScript's import syntax. 我说它更合适,因为它使用TypeScript的导入语法。
Also, there's a clear explanation - by AWS - on how to use TS with AWS SDK here . 此外,有一个明确的解释 - 由AWS - 如何在这里使用TS与AWS SDK 。
Change to : 改成 :
import AWS = require('aws-sdk');
var ses:AWS.SES = new AWS.SES();
Note: if import
is unclear you probably want to read up on modules : https://basarat.gitbooks.io/typescript/content/docs/project/modules.html 注意:如果
import
不清楚,您可能需要阅读模块: https : //basarat.gitbooks.io/typescript/content/docs/project/modules.html
TIP: always a good idea to see the test file for intended usage : https://github.com/borisyankov/DefinitelyTyped/blob/master/aws-sdk/aws-sdk-tests.ts 提示:总是一个好主意,看看测试文件是否符合预期用途: https : //github.com/borisyankov/DefinitelyTyped/blob/master/aws-sdk/aws-sdk-tests.ts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.