From 5c0ac3416bf4c2a40a9dee93cc29b24445ad3655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 16 Apr 2019 09:02:43 +0200 Subject: [PATCH 1/2] fix: Use different symbol for Stack.isStack versus CfnReference.isCfnReference --- packages/@aws-cdk/cdk/lib/stack.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/cdk/lib/stack.ts b/packages/@aws-cdk/cdk/lib/stack.ts index ed1023ffaee36..ab300722f43a5 100644 --- a/packages/@aws-cdk/cdk/lib/stack.ts +++ b/packages/@aws-cdk/cdk/lib/stack.ts @@ -42,7 +42,7 @@ export interface StackProps { readonly autoDeploy?: boolean; } -const STACK_SYMBOL = Symbol('@aws-cdk/cdk.CfnReference'); +const STACK_SYMBOL = Symbol('@aws-cdk/cdk.Stack'); /** * A root construct which represents a single CloudFormation stack. @@ -66,8 +66,8 @@ export class Stack extends Construct { * * We do attribute detection since we can't reliably use 'instanceof'. */ - public static isStack(x: any): x is Stack { - return x[STACK_SYMBOL] === true; + public static isStack(obj: any): obj is Stack { + return obj[STACK_SYMBOL] === true; } private static readonly VALID_STACK_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/; @@ -676,4 +676,4 @@ function findResources(roots: Iterable): CfnResource[] { interface StackDependency { stack: Stack; reason: string; -} \ No newline at end of file +} From a3446eeb3aa8f4d3f7a1e8833fe0cdbcdfe125e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 16 Apr 2019 10:51:06 +0200 Subject: [PATCH 2/2] Use Symbol.for --- packages/@aws-cdk/cdk/lib/cfn-reference.ts | 4 ++-- packages/@aws-cdk/cdk/lib/reference.ts | 4 ++-- packages/@aws-cdk/cdk/lib/stack.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/cdk/lib/cfn-reference.ts b/packages/@aws-cdk/cdk/lib/cfn-reference.ts index 9d533f4778d79..24cb71b37aba9 100644 --- a/packages/@aws-cdk/cdk/lib/cfn-reference.ts +++ b/packages/@aws-cdk/cdk/lib/cfn-reference.ts @@ -1,6 +1,6 @@ import { Reference } from "./reference"; -const CFN_REFERENCE_SYMBOL = Symbol('@aws-cdk/cdk.CfnReference'); +const CFN_REFERENCE_SYMBOL = Symbol.for('@aws-cdk/cdk.CfnReference'); /** * A Token that represents a CloudFormation reference to another resource @@ -112,4 +112,4 @@ export class CfnReference extends Reference { import { CfnOutput } from "./cfn-output"; import { Construct, IConstruct } from "./construct"; import { Stack } from "./stack"; -import { ResolveContext, Token } from "./token"; \ No newline at end of file +import { ResolveContext, Token } from "./token"; diff --git a/packages/@aws-cdk/cdk/lib/reference.ts b/packages/@aws-cdk/cdk/lib/reference.ts index e9a91da8c4967..791f67c7945e4 100644 --- a/packages/@aws-cdk/cdk/lib/reference.ts +++ b/packages/@aws-cdk/cdk/lib/reference.ts @@ -1,6 +1,6 @@ import { Token } from "./token"; -const REFERENCE_SYMBOL = Symbol('@aws-cdk/cdk.Reference'); +const REFERENCE_SYMBOL = Symbol.for('@aws-cdk/cdk.Reference'); /** * A Token that represents a reference between two constructs @@ -24,4 +24,4 @@ export class Reference extends Token { } } -import { Construct } from "./construct"; \ No newline at end of file +import { Construct } from "./construct"; diff --git a/packages/@aws-cdk/cdk/lib/stack.ts b/packages/@aws-cdk/cdk/lib/stack.ts index ab300722f43a5..ed63d77e9e5d7 100644 --- a/packages/@aws-cdk/cdk/lib/stack.ts +++ b/packages/@aws-cdk/cdk/lib/stack.ts @@ -42,7 +42,7 @@ export interface StackProps { readonly autoDeploy?: boolean; } -const STACK_SYMBOL = Symbol('@aws-cdk/cdk.Stack'); +const STACK_SYMBOL = Symbol.for('@aws-cdk/cdk.Stack'); /** * A root construct which represents a single CloudFormation stack.