diff --git a/packages/@aws-cdk/cdk/lib/app.ts b/packages/@aws-cdk/cdk/lib/app.ts index f3e7c6a90ff8a..3892bd72bdc1d 100644 --- a/packages/@aws-cdk/cdk/lib/app.ts +++ b/packages/@aws-cdk/cdk/lib/app.ts @@ -1,7 +1,7 @@ import cxapi = require('@aws-cdk/cx-api'); import fs = require('fs'); import path = require('path'); -import { Stack } from './cloudformation/stack'; +import { isStack, Stack } from './cloudformation/stack'; import { Construct, MetadataEntry, PATH_SEP, Root } from './core/construct'; import { resolve } from './core/tokens'; @@ -21,8 +21,8 @@ export class App extends Root { private get stacks() { const out: { [name: string]: Stack } = { }; for (const child of this.children) { - if (!(child instanceof Stack)) { - throw new Error(`The child ${child.toString()} of Program must be a Stack`); + if (!isStack(child)) { + throw new Error(`The child ${child.toString()} of App must be a Stack`); } out[child.id] = child as Stack; diff --git a/packages/@aws-cdk/cdk/lib/cloudformation/stack.ts b/packages/@aws-cdk/cdk/lib/cloudformation/stack.ts index 5e97d935a8ed6..04182776660cb 100644 --- a/packages/@aws-cdk/cdk/lib/cloudformation/stack.ts +++ b/packages/@aws-cdk/cdk/lib/cloudformation/stack.ts @@ -438,7 +438,7 @@ export abstract class Referenceable extends StackElement { * * We do attribute detection since we can't reliably use 'instanceof'. */ -function isStack(construct: Construct): construct is Stack { +export function isStack(construct: Construct): construct is Stack { return (construct as any).isStack; }