From 6e0aa13c7bf220837f79b43506bee4e35b969fb3 Mon Sep 17 00:00:00 2001 From: dali546 <35352237+dali546@users.noreply.github.com> Date: Mon, 10 Mar 2025 19:03:42 +0000 Subject: [PATCH] chore: add undefined type to principalAccount (#33055) ### Reason for this change When using TypeScript option exactOptionalPropertyTypes: true` we get the following error. All implementations of `IPrincipal` have the type `string | undefined` so this is change will apply it at the base ``` Type 'AccountPrincipal' is not assignable to type 'IPrincipal' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. Types of property 'principalAccount' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'.ts(2375) ``` ### Description of changes Changed type definition of IPrincipal `principalAccount` ### Describe any new or updated permissions being added N/A ### Description of how you validated changes ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk-lib/aws-iam/lib/principals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-iam/lib/principals.ts b/packages/aws-cdk-lib/aws-iam/lib/principals.ts index 35fbb69fb76f2..79e00d9e85cc5 100644 --- a/packages/aws-cdk-lib/aws-iam/lib/principals.ts +++ b/packages/aws-cdk-lib/aws-iam/lib/principals.ts @@ -53,7 +53,7 @@ export interface IPrincipal extends IGrantable { * Can be a Token - in that case, * it's assumed to be AWS::AccountId. */ - readonly principalAccount?: string; + readonly principalAccount?: string | undefined; /** * Add to the policy of this principal.