diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts index cbf1ba70a3..1454309b93 100644 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -1,12 +1,12 @@ import * as Alexa from "alexa-sdk"; -const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { +const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { let alexa = Alexa.handler(event, context); alexa.registerHandlers(handlers); alexa.execute(); }; -let handlers: Alexa.Handlers = { +let handlers: Alexa.Handlers = { 'LaunchRequest': function() { this.emit('SayHello'); }, diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 256d3fee9a..24baccf484 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -6,14 +6,14 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void ): AlexaObject; +export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void ): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; -export interface AlexaObject extends Handler { +export interface AlexaObject extends Handler { _event: any; _context: any; _callback: any; @@ -22,26 +22,26 @@ export interface AlexaObject extends Handler { response: any; dynamoDBTableName: any; saveBeforeResponse: boolean; - registerHandlers: (...handlers: Handlers[]) => any; + registerHandlers: (...handlers: Array>) => any; execute: () => void; } -export interface Handlers { - [intent: string]: (this: Handler) => void; +export interface Handlers { + [intent: string]: (this: Handler) => void; } -export interface Handler { +export interface Handler { on: any; emit(event: string, ...args: any[]): boolean; emitWithState: any; state: any; handler: any; - event: RequestBody; + event: RequestBody; attributes: any; context: any; name: any; isOverriden: any; - t: (token: string) => void; + t: (token: string, ...args: any[]) => void; } export interface Context { @@ -55,10 +55,10 @@ export interface Context { awsRequestId: string; } -export interface RequestBody { +export interface RequestBody { version: string; session: Session; - request: LaunchRequest | IntentRequest | SessionEndedRequest; + request: T; } export interface Session { @@ -75,36 +75,37 @@ export interface SessionApplication { export interface SessionUser { userId: string; - accessToken: string; + accessToken?: string; } export interface LaunchRequest extends Request { } export interface IntentRequest extends Request { - dialogState: DialogStates; - intent: Intent; -} - -export interface SlotValue { - confirmationStatus: ConfirmationStatuses; - name: string; - value?: any; -} - -export interface Intent { - confirmationStatus: ConfirmationStatuses; - name: string; - slots: Record; + dialogState?: DialogStates; + intent?: Intent; } export interface SessionEndedRequest extends Request { - reason: string; + reason?: string; } export interface Request { type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; requestId: string; - timeStamp: string; + timestamp: string; + locale?: string; +} + +export interface SlotValue { + confirmationStatus?: ConfirmationStatuses; + name: string; + value?: any; +} + +export interface Intent { + confirmationStatus?: ConfirmationStatuses; + name: string; + slots: Record; } export interface ResponseBody { diff --git a/types/alexa-sdk/tslint.json b/types/alexa-sdk/tslint.json index 0c1ca3b5b4..78f1939ba2 100644 --- a/types/alexa-sdk/tslint.json +++ b/types/alexa-sdk/tslint.json @@ -4,6 +4,7 @@ "object-literal-key-quote": false, "no-empty-interface": false, "prefer-method-signature": false, - "object-literal-key-quotes": false + "object-literal-key-quotes": false, + "no-any": false } }