Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Argument of type 'this' is not assignable to parameter of type 'Construct'. #102

Closed
moltar opened this issue Jun 6, 2022 · 5 comments
Closed

Comments

@moltar
Copy link
Contributor

moltar commented Jun 6, 2022

It looks like the constructs packages is outdated and I am getting the type conflicts with the latest version.

My project:

    "constructs": "10.1.28",

Argument of type 'this' is not assignable to parameter of type 'Construct'.

Argument of type 'this' is not assignable to parameter of type 'Construct'.
  Type 'AWSBootstrapKitLandingZoneStage' is not assignable to type 'Construct'.
    Types of property 'node' are incompatible.
      Type 'import(".../node_modules/constructs/lib/construct").Node' is not assignable to type 'import(".../node_modules/aws-bootstrap-kit/node_modules/constructs/lib/construct").Node'.
        Types have separate declarations of a private property 'host'.
@flochaz
Copy link
Contributor

flochaz commented Jun 7, 2022

That is weird, you should be able to use whatever version since we added ^ in peer deps: https://github.com/awslabs/aws-bootstrap-kit/pull/77/files

@moltar
Copy link
Contributor Author

moltar commented Jun 7, 2022

Yeah, I thought that was odd as well.

@moltar
Copy link
Contributor Author

moltar commented Jun 7, 2022

Wait, the dependencies value is still fixed though!

"dependencies": {
"aws-cdk-lib": "2.1.0",
"constructs": "10.0.12"
},
"peerDependencies": {
"aws-cdk-lib": "^2.1.0",
"constructs": "^10.0.12"
}

@flochaz
Copy link
Contributor

flochaz commented Jun 7, 2022

You can solve this by adding the following block to your package.json :

"overrides": {
      "aws-bootstrap-kit": {
        "aws-cdk-lib": "2.27.0",
        "constructs": "10.1.31"
      }
    }

and make sure to pin prettier types in your dev deps (aws/aws-cdk#20319)

"@types/prettier": "2.6.0"

@moltar
Copy link
Contributor Author

moltar commented Jul 13, 2022

Ok, this worked. But this requires npm@8. This may not affect many people, but still good to know.

Another pro tip, it is possible to use references to the package versions you already have installed:

  "overrides": {
    "aws-cdk-lib": "$aws-cdk-lib",
    "constructs": "$constructs"
  }

@moltar moltar closed this as completed Jul 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants