Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use different symbol for Stack.isStack versus CfnReference.isCfnReference #2305

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}