Skip to content

Commit

Permalink
fix(core): Use different symbol for Stack.isStack versus CfnReference…
Browse files Browse the repository at this point in the history
….isCfnReference (#2305)
  • Loading branch information
RomainMuller authored Apr 16, 2019
1 parent a89758f commit c1e41ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cdk/lib/cfn-reference.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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";
import { ResolveContext, Token } from "./token";
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cdk/lib/reference.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,4 +24,4 @@ export class Reference extends Token {
}
}

import { Construct } from "./construct";
import { Construct } from "./construct";
8 changes: 4 additions & 4 deletions packages/@aws-cdk/cdk/lib/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface StackProps {
readonly autoDeploy?: boolean;
}

const STACK_SYMBOL = Symbol('@aws-cdk/cdk.CfnReference');
const STACK_SYMBOL = Symbol.for('@aws-cdk/cdk.Stack');

/**
* A root construct which represents a single CloudFormation stack.
Expand All @@ -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-]*$/;
Expand Down Expand Up @@ -676,4 +676,4 @@ function findResources(roots: Iterable<IConstruct>): CfnResource[] {
interface StackDependency {
stack: Stack;
reason: string;
}
}

0 comments on commit c1e41ed

Please sign in to comment.