Skip to content

Commit

Permalink
fix(core): use any type for context (#9014)
Browse files Browse the repository at this point in the history
fixes #8865
  • Loading branch information
fogfish committed Jul 16, 2020
1 parent a962a49 commit 375335e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface AppProps {
*
* @default - no additional context
*/
readonly context?: { [key: string]: string };
readonly context?: { [key: string]: any };

/**
* Include construct tree metadata as part of the Cloud Assembly.
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/core/test/test.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,22 @@ export = {

test.done();
},

'application support any type in context'(test: Test) {
const app = new App({
context: {
isString: 'string',
isNumber: 10,
isObject: { isString: 'string', isNumber: 10 },
},
});

test.ok(app.node.tryGetContext('isString') === 'string');
test.ok(app.node.tryGetContext('isNumber') === 10);
test.deepEqual(app.node.tryGetContext('isObject'), { isString: 'string', isNumber: 10 });

test.done();
},
};

class MyConstruct extends Construct {
Expand Down

0 comments on commit 375335e

Please sign in to comment.