Skip to content

Commit

Permalink
feat: Add TypeScript Generics on the getSessionAttributes Method (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
hideokamoto authored and ShenChen93 committed Jun 27, 2019
1 parent 89173bc commit 0824495
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ask-sdk-core/lib/attributes/AttributesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface AttributesManager {
* Provides session attributes extracted from request envelope.
* @returns {Object.<string, any>}
*/
getSessionAttributes() : {[key : string] : any};
getSessionAttributes<T = {[key : string] : any}>() : T;
/**
* Provides persistent attributes retrieved and cached from persistence adapter.
* @returns {Promise<Object.<string, any>>}
Expand Down
4 changes: 2 additions & 2 deletions ask-sdk-core/lib/attributes/AttributesManagerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export class AttributesManagerFactory {
getRequestAttributes() : {[key : string] : any} {
return thisRequestAttributes;
},
getSessionAttributes() : {[key : string] : any} {
getSessionAttributes<T = {[key : string] : any}>() : T {
if (!options.requestEnvelope.session) {
throw createAskSdkError(
'AttributesManager',
'Cannot get SessionAttributes from out of session request!');
}

return thisSessionAttributes;
return thisSessionAttributes as T;
},
async getPersistentAttributes() : Promise<{[key : string] : any}> {
if (!options.persistenceAdapter) {
Expand Down

0 comments on commit 0824495

Please sign in to comment.