Alexa-skills-kit-sdk-for-nodejs: TypeScript Definitions

Created on 30 Sep 2016  ·  2Comments  ·  Source: alexa/alexa-skills-kit-sdk-for-nodejs

It'd be great if we can get some TypeScript definitions written for this SDK. With TypeScript 2.0 recently being released and with huge support from Angular 2.0, TypeScript is gaining some serious traction in Enterprise Javascript Projects.

Some are already available from DefinatelyTyped, but they don't appear complete or up-to-date with this SDK /repo. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/alexa-sdk/alexa-sdk.d.ts

Most helpful comment

At this point we don't have typescript definitions -- but converting this SDK to typescript may be something we could look into in the future

thank you @bill-mybiz for the link, closing this

All 2 comments

I've gone through those definitions @schodemeiss linked to, and I wanted to let you know that I also have a definition set a bit more filled out (including docs) already created if you wanted to just use that. It looks like they are 99% compatible. Slight differences, like instead of using literals in the type such as this in yours:

interface IRequest {
        type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest";
        requestId: string;
        timeStamp: string;
}

I have the following:

/** String literal with possible values. Used in place of an enum to allow string type. */
export type RequestType = 'LaunchRequest' | 'IntentRequest' | 'SessionEndedRequest';
export const RequestType = {
    LaunchRequest: 'LaunchRequest' as RequestType,
    IntentRequest: 'IntentRequest' as RequestType,
    SessionEndedRequest: 'SessionEndedRequest' as RequestType
};

/**
 * Request made to an Alexa skill. This is an "abstract base class" interface.
 *
 * Called "AlexaRequest" instead of just Request to show that this is not the "request" object per se, but specific to the Alexa domain.
 */
export interface AlexaRequest {
    /**
     * Type of concrete request.
     * @see RequestType
     * */
    type: RequestType,
    /** Represents the unique identifier for the specific request. */
    requestId: string
    /** Provides the date and time when Alexa sent the request. Use this to verify that the request is current and not part of a “replay” attack. Timestamp is provided as an ISO 8601 formatted string (for example, 2015-05-13T12:34:56Z). */
    timestamp: string,
}

I just wanted to let you know of the existence of this.

Also, as a side note, TypeScript recommends against prefixing interfaces with "I", so IRequest more idiomatically is Request.

At this point we don't have typescript definitions -- but converting this SDK to typescript may be something we could look into in the future

thank you @bill-mybiz for the link, closing this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dkl3in picture dkl3in  ·  3Comments

slesem picture slesem  ·  4Comments

mehtanilay10 picture mehtanilay10  ·  6Comments

lostvicking picture lostvicking  ·  4Comments

ancashoria picture ancashoria  ·  6Comments