Skip to content

Commit

Permalink
fix(core): fix some return types (#3192)
Browse files Browse the repository at this point in the history
1. `@aws-cdk/core.Stack.availabilityZones`:
   The type was incorrectly inferred to `any` by the typescript compiler,
   however the actual type `string[]`.
2. `@aws-cdk/aws-codebuild.Project.addSecondaryArtifact(IArtifacts)`:
   The type was declared as `any`, however the function never returns
   anything - the effective type is `void`.
3. Renamed `@aws-cdk/aws-ec2.toRuleJSON` to `toRuleJson` for consistency.
  • Loading branch information
RomainMuller committed Jul 4, 2019
1 parent 3a9fa64 commit b5997c3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
change-return-type:@aws-cdk/aws-codebuild.PipelineProject.addSecondaryArtifact
change-return-type:@aws-cdk/aws-codebuild.Project.addSecondaryArtifact
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ export class Project extends ProjectBase {
* @param secondaryArtifact the artifact to add as a secondary artifact
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
*/
public addSecondaryArtifact(secondaryArtifact: IArtifacts): any {
public addSecondaryArtifact(secondaryArtifact: IArtifacts): void {
if (!secondaryArtifact.identifier) {
throw new Error("The identifier attribute is mandatory for secondary artifacts");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
removed:@aws-cdk/aws-ec2.Port.toRuleJSON
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2/lib/port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class Port {
/**
* Produce the ingress/egress rule JSON for the given connection
*/
public toRuleJSON(): any {
public toRuleJson(): any {
return {
ipProtocol: this.props.protocol,
fromPort: this.props.fromPort,
Expand All @@ -198,4 +198,4 @@ export class Port {

function renderPort(port: number) {
return Token.isUnresolved(port) ? `{IndirectPort}` : port.toString();
}
}
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ec2/lib/security-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup {
new CfnSecurityGroupIngress(scope, id, {
groupId: this.securityGroupId,
...peer.toIngressRuleConfig(),
...connection.toRuleJSON(),
...connection.toRuleJson(),
description
});
}
Expand All @@ -94,7 +94,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup {
new CfnSecurityGroupEgress(scope, id, {
groupId: this.securityGroupId,
...peer.toEgressRuleConfig(),
...connection.toRuleJSON(),
...connection.toRuleJson(),
description
});
}
Expand Down Expand Up @@ -298,7 +298,7 @@ export class SecurityGroup extends SecurityGroupBase {

this.addDirectIngressRule({
...peer.toIngressRuleConfig(),
...connection.toRuleJSON(),
...connection.toRuleJson(),
description
});
}
Expand Down Expand Up @@ -327,7 +327,7 @@ export class SecurityGroup extends SecurityGroupBase {

const rule = {
...peer.toEgressRuleConfig(),
...connection.toRuleJSON(),
...connection.toRuleJson(),
description
};

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class Stack extends Construct implements ITaggable {
* reports them as missing, and let the CLI resolve them by calling EC2
* `DescribeAvailabilityZones` on the target environment.
*/
public get availabilityZones() {
public get availabilityZones(): string[] {
// if account/region are tokens, we can't obtain AZs through the context
// provider, so we fallback to use Fn::GetAZs. the current lowest common
// denominator is 2 AZs across all AWS regions.
Expand Down
1 change: 1 addition & 0 deletions scripts/check-api-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ for i in ${!package_dirs[*]}; do
if [[ ! -d $tmpdir/node_modules/${package_names[$i]} ]]; then continue; fi
echo -n "${package_names[$i]}... "
if npx jsii-diff \
--keys \
--ignore-file ${package_dirs[$i]}/allowed-breaking-changes-${current_version}.txt \
$tmpdir/node_modules/${package_names[$i]} \
${package_dirs[$i]} \
Expand Down

0 comments on commit b5997c3

Please sign in to comment.