Skip to content

Commit

Permalink
chore: fix build (#2856)
Browse files Browse the repository at this point in the history
Can't declare 'protected ref' on one class and then 'public ref' on a
subclass.

Remove the shared base base class 'ref' because it's not very useful
anyway and only used in one place.

Conditions shouldn't be `CfnRefElements`, because they can't be
`{ Ref }`ed.
  • Loading branch information
rix0rrr committed Jun 13, 2019
1 parent 902636a commit 849b693
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cdk/lib/cfn-condition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CfnRefElement } from './cfn-element';
import { CfnElement } from './cfn-element';
import { Construct } from './construct';
import { IResolvable, IResolveContext } from './resolvable';

Expand All @@ -15,7 +15,7 @@ export interface CfnConditionProps {
* Represents a CloudFormation condition, for resources which must be conditionally created and
* the determination must be made at deploy time.
*/
export class CfnCondition extends CfnRefElement implements ICfnConditionExpression, IResolvable {
export class CfnCondition extends CfnElement implements ICfnConditionExpression, IResolvable {
public readonly displayHint: string | undefined;

/**
Expand Down
9 changes: 1 addition & 8 deletions packages/@aws-cdk/cdk/lib/cfn-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,6 @@ export abstract class CfnElement extends Construct {
}
}

/**
* Return a token that will CloudFormation { Ref } this stack element
*/
protected get ref(): IResolvable {
return CfnReference.for(this, 'Ref');
}

/**
* Called during synthesize to render the logical ID of this element. If
* `overrideLogicalId` was it will be used, otherwise, we will allocate the
Expand Down Expand Up @@ -174,7 +167,7 @@ export abstract class CfnRefElement extends CfnElement {
* Return a token that will CloudFormation { Ref } this stack element
*/
public get ref(): IResolvable {
return super.ref;
return CfnReference.for(this, 'Ref');
}

/**
Expand Down
11 changes: 6 additions & 5 deletions packages/@aws-cdk/cdk/lib/cfn-parameter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CfnElement } from './cfn-element';
import { Construct } from './construct';
import { CfnReference } from './private/cfn-reference';
import { IResolvable, IResolveContext } from './resolvable';
import { Token } from './token';

Expand Down Expand Up @@ -125,7 +126,7 @@ export class CfnParameter extends CfnElement implements IResolvable {
* The parameter value as a Token
*/
public get value(): IResolvable {
return super.ref;
return CfnReference.for(this, 'Ref');
}

/**
Expand All @@ -135,7 +136,7 @@ export class CfnParameter extends CfnElement implements IResolvable {
if (!isStringType(this.type)) {
throw new Error(`Parameter type (${this.type}) is not a string type`);
}
return Token.asString(this.ref);
return Token.asString(this.value);
}

/**
Expand All @@ -145,7 +146,7 @@ export class CfnParameter extends CfnElement implements IResolvable {
if (!isListType(this.type)) {
throw new Error(`Parameter type (${this.type}) is not a string list type`);
}
return Token.asList(this.ref);
return Token.asList(this.value);
}

/**
Expand All @@ -155,7 +156,7 @@ export class CfnParameter extends CfnElement implements IResolvable {
if (!isNumberType(this.type)) {
throw new Error(`Parameter type (${this.type}) is not a number type`);
}
return Token.asNumber(this.ref);
return Token.asNumber(this.value);
}

/**
Expand All @@ -182,7 +183,7 @@ export class CfnParameter extends CfnElement implements IResolvable {
}

public resolve(_context: IResolveContext): any {
return this.ref;
return this.value;
}
}

Expand Down

0 comments on commit 849b693

Please sign in to comment.