Skip to content

Commit b5997c3

Browse files
authored
fix(core): fix some return types (#3192)
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.
1 parent 3a9fa64 commit b5997c3

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
change-return-type:@aws-cdk/aws-codebuild.PipelineProject.addSecondaryArtifact
2+
change-return-type:@aws-cdk/aws-codebuild.Project.addSecondaryArtifact

packages/@aws-cdk/aws-codebuild/lib/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ export class Project extends ProjectBase {
734734
* @param secondaryArtifact the artifact to add as a secondary artifact
735735
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
736736
*/
737-
public addSecondaryArtifact(secondaryArtifact: IArtifacts): any {
737+
public addSecondaryArtifact(secondaryArtifact: IArtifacts): void {
738738
if (!secondaryArtifact.identifier) {
739739
throw new Error("The identifier attribute is mandatory for secondary artifacts");
740740
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
removed:@aws-cdk/aws-ec2.Port.toRuleJSON

packages/@aws-cdk/aws-ec2/lib/port.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class Port {
183183
/**
184184
* Produce the ingress/egress rule JSON for the given connection
185185
*/
186-
public toRuleJSON(): any {
186+
public toRuleJson(): any {
187187
return {
188188
ipProtocol: this.props.protocol,
189189
fromPort: this.props.fromPort,
@@ -198,4 +198,4 @@ export class Port {
198198

199199
function renderPort(port: number) {
200200
return Token.isUnresolved(port) ? `{IndirectPort}` : port.toString();
201-
}
201+
}

packages/@aws-cdk/aws-ec2/lib/security-group.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup {
7676
new CfnSecurityGroupIngress(scope, id, {
7777
groupId: this.securityGroupId,
7878
...peer.toIngressRuleConfig(),
79-
...connection.toRuleJSON(),
79+
...connection.toRuleJson(),
8080
description
8181
});
8282
}
@@ -94,7 +94,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup {
9494
new CfnSecurityGroupEgress(scope, id, {
9595
groupId: this.securityGroupId,
9696
...peer.toEgressRuleConfig(),
97-
...connection.toRuleJSON(),
97+
...connection.toRuleJson(),
9898
description
9999
});
100100
}
@@ -298,7 +298,7 @@ export class SecurityGroup extends SecurityGroupBase {
298298

299299
this.addDirectIngressRule({
300300
...peer.toIngressRuleConfig(),
301-
...connection.toRuleJSON(),
301+
...connection.toRuleJson(),
302302
description
303303
});
304304
}
@@ -327,7 +327,7 @@ export class SecurityGroup extends SecurityGroupBase {
327327

328328
const rule = {
329329
...peer.toEgressRuleConfig(),
330-
...connection.toRuleJSON(),
330+
...connection.toRuleJson(),
331331
description
332332
};
333333

packages/@aws-cdk/core/lib/stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export class Stack extends Construct implements ITaggable {
390390
* reports them as missing, and let the CLI resolve them by calling EC2
391391
* `DescribeAvailabilityZones` on the target environment.
392392
*/
393-
public get availabilityZones() {
393+
public get availabilityZones(): string[] {
394394
// if account/region are tokens, we can't obtain AZs through the context
395395
// provider, so we fallback to use Fn::GetAZs. the current lowest common
396396
// denominator is 2 AZs across all AWS regions.

scripts/check-api-compatibility.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ for i in ${!package_dirs[*]}; do
5353
if [[ ! -d $tmpdir/node_modules/${package_names[$i]} ]]; then continue; fi
5454
echo -n "${package_names[$i]}... "
5555
if npx jsii-diff \
56+
--keys \
5657
--ignore-file ${package_dirs[$i]}/allowed-breaking-changes-${current_version}.txt \
5758
$tmpdir/node_modules/${package_names[$i]} \
5859
${package_dirs[$i]} \

0 commit comments

Comments
 (0)