Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Role): role.d.ts[24,14] Class Role incorrectly implements interface IRole #15150

Closed
normjon opened this issue Jun 16, 2021 · 10 comments
Closed
Assignees
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@normjon
Copy link

normjon commented Jun 16, 2021

Reproduction Steps

What did you expect to happen?

What actually happened?

Environment

  • **CDK CLI Version :1.107.0 (build 52c4434)
  • **Framework Version:1.108.1
  • **Node.js Version:v16.3.0
  • **OS :MAC
  • **Language (Version):Typescript

Other


This is 🐛 Bug Report

@normjon normjon added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2021
@peterwoodworth
Copy link
Contributor

Hey @normjon, without more information I'm not able to help you. Can you tell me more about your problem?

@peterwoodworth peterwoodworth added guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 17, 2021
@peterwoodworth peterwoodworth self-assigned this Jun 17, 2021
@normjon
Copy link
Author

normjon commented Jun 19, 2021

I thought I provided details, but clearly I didn't. Here you go.

Example code giving error:
const role = new iam.Role(this, 'myRole', {
assumedBy: new iam.AccountPrincipal('1234')
});

Error description coming from IDE:
Type 'AccountPrincipal' is not assignable to type 'IPrincipal'.
Types of property 'principalAccount' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.

Error description for Class Role (role.d.ts):
Class 'Role' incorrectly implements interface 'IRole'.
Types of property 'principalAccount' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.

Let me know if more details are needed.

Thanks

@peterwoodworth
Copy link
Contributor

Can you check your package.json to make sure all CDK related packages are the same version?

@mweitzel2005
Copy link

@peterwoodworth response worked for me when I got the following error: Type 'Role' is not assignable to type 'IRole'.
CDK dependencies installed after the initialisation had a higher version number than the core package. Set them all to the same version as the core package and it works (i.e. no errors).

@peterwoodworth
Copy link
Contributor

Yup, that's the most common cause of this error, it's likely what happened to @normjon as well

@peterwoodworth peterwoodworth added closing-soon This issue will automatically close in 4 days unless further comments are made. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jun 23, 2021
@peterwoodworth
Copy link
Contributor

Ping me if you need any more help with this 😄

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@normjon
Copy link
Author

normjon commented Jun 28, 2021

Thanks for looking into this. I'll be sure to check the library and core versions

@BwL1289
Copy link

BwL1289 commented May 10, 2022

@peterwoodworth Having an issue with this (using Python and CDKv2 in my case).

Error (using PyLance):

Argument of type "Role" cannot be assigned to parameter "role" of type "IRole | None" in function "__init__"
  Type "Role" cannot be assigned to type "IRole | None"
    "Role" is incompatible with protocol "IRole"
      "grant_pass_role" is an incompatible type
        Type "(identity: IPrincipal) -> Grant" cannot be assigned to type "(grantee: IPrincipal) -> Grant"
          Parameter name mismatch: "grantee" versus "identity"
    Type cannot be assigned to type 

Steps I've taken to mitigate, given feedback above:

  1. Deactivate and delete my virtual environment
  2. Updated my constraints.txt file with the following versions:
pytest==6.2.5
boto3==1.20.37
aws-cdk-lib==2.23.0
constructs==10.1.5
cdk8s==2.2.85
cfnresponse==1.1.2
  1. Updated npm: npm update
  2. Updated aws CLI: npm i -g aws-cdk
  3. Created new virtual environment: python3 -m venv .venv
  4. Activated my virtual environment: . .venv/bin/activate
  5. Install requirements: pip install -r requirements.txt -r requirements-dev.txt -c constraints.txt

Still seeing this error :/. I'm not sure how the Pipfile plays into this, but would appreciate any clarification possible.

Also, please let me know if I should create a new issue :).

@tejasmr
Copy link
Contributor

tejasmr commented May 12, 2022

Can you try npm i -g aws-cdk@2.23.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

5 participants