-
Couldn't load subscription status.
- Fork 4.3k
Description
Describe the bug
The AccountPrinciple class as found in: https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-iam/lib/principals.ts#L395 has a construct that takes a single argument which is the accountId the type of this 'account id' parameter is any. Can this parameter be changed to be of type string instead?
Expected Behavior
I expect the following piece of code to give a Type error on the first parameter.
new aws_iam.AccountPrincipal({ hello: 'world' }); // This is currently valid, and should not be, it should throw a TypeError
new aws_iam.AccountPrincipal('0123456789012'); // This is valid, and should beCurrent Behavior
Currently, TypeScript does not complain about the code below.
new aws_iam.AccountPrincipal({ hello: 'world' }); // This is currently valid, and should not be, it should throw a TypeError
new aws_iam.AccountPrincipal('0123456789012'); // This is valid, and should beReproduction Steps
import { aws_iam } from 'aws-cdk-lib';
new aws_iam.AccountPrincipal('0123456789012');
new aws_iam.AccountPrincipal({ hello: 'world' });
Possible Solution
To fix this we can simply replace any with string in the constructor parameter of the AccountPrinciple class in: https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-iam/lib/principals.ts#L395
But first, we should double check there isn't any reasoning behind this being of type any.
Additional Information/Context
No response
CDK CLI Version
2.16.0 (build 4c77925)
Framework Version
No response
Node.js Version
v14.18.0
OS
MacOS
Language
Typescript
Language Version
3.9.7
Other information
No response