2017-01-02 35 views
0

我試圖使用AWS SDK和下面的官方AWS-SDK鏈接(https://www.npmjs.com/package/aws-sdkAWS SDK不能在角CLI項目被稱爲

ERROR in ./src/app/service/aws.service.ts 
Module build failed: Error: /Users/slin/pan/protego/crossbow/src/app/service/aws.service.ts (26,13): Argument of type '{ region: string; accessKeyId: string; secretAccessKey: string; }' is not assignable to parameter of type 'ConfigurationOptions & ConfigurationServicePlaceholders & APIVersions'. 
    Object literal may only specify known properties, and 'accessKeyId' does not exist in type 'ConfigurationOptions & ConfigurationServicePlaceholders & APIVersions'.) 
    at _checkDiagnostics (/Users/slin/pan/protego/crossbow/node_modules/@ngtools/webpack/src/loader.js:116:15) 
    at /Users/slin/pan/protego/crossbow/node_modules/@ngtools/webpack/src/loader.js:141:17 
    at tryCatch (/Users/slin/pan/protego/crossbow/node_modules/es6-promise/dist/es6-promise.js:410:12) 
    at invokeCallback (/Users/slin/pan/protego/crossbow/node_modules/es6-promise/dist/es6-promise.js:425:13) 
    at publish (/Users/slin/pan/protego/crossbow/node_modules/es6-promise/dist/es6-promise.js:393:7) 
    at flush (/Users/slin/pan/protego/crossbow/node_modules/es6-promise/dist/es6-promise.js:121:5) 
    at nextTickCallbackWith0Args (node.js:415:9) 
    at process._tickCallback (node.js:344:13) 
@ ./src/app/app.module.ts 17:0-51 
@ ./src/main.ts 
@ multi main 
後得到了一個全新的CLI angular2這個項目打字稿生成錯誤

我的代碼,因爲這只是簡單的:

import { Injectable } from "@angular/core"; 
import * as AWS from 'aws-sdk'; 

@Injectable() 
export class AwsService { 
    loggedin: boolean; 
    aws_accessKeyId: string; 
    aws_secretAccessKey: string; 
    aws_region: string; 

    constructor() { 
     this.loggedin = false; 
     this.aws_region = 'us-west-2'; 
    } 

    login(
    ) { 
     AWS.config.update({ 
      region: this.aws_region, 
      accessKeyId: this.aws_accessKeyId, 
      secretAccessKey: this.aws_secretAccessKey 
     }); 
     this.loggedin = true; 
     console.log(this.aws_accessKeyId, this.aws_secretAccessKey); 
    } 
} 

是對AWS-SDK真正爲打字稿工作?或者我錯過了angular2-cli項目的一些設置?難道這個問題aws-sdk不支持es6嗎?

任何幫助表示讚賞!

回答

1

好吧,我發現我的問題。它實際上只是遵循angular-cli指令。我的問題是aws最新的API已被更改,但他們沒有更新他們的api文檔。

的^ 2.7.11語法應爲:

AWS.config.update({ 
     region: this.aws_region, 
     credentials: { 
      accessKeyId: this.aws_accessKeyId, 
      secretAccessKey: this.aws_secretAccessKey 
     } 
    });