I'm getting this same error while working through the AWS CDK Workshop.
Argument of type 'this' is not assignable to parameter of type 'Construct'.
Type 'HitCounter' is not assignable to type 'Construct'.
Types of property 'node' are incompatible.
Type 'import("/Users/dev_user/code/aws/cdk/cdk-workshop/node_modules/@aws-cdk/core/lib/construct").ConstructNode' is not assignable to type
'import("/Users/dev_user/code/aws/cdk/cdk-workshop/node_modules/@aws-cdk/aws-dynamodb/node_modules/@aws-cdk/core/lib/construct").ConstructNode'.
Types have separate declarations of a private property 'host'.ts(2345)
Following is the package.json
{
"name": "cdk-workshop",
"version": "0.1.0",
"bin": {
"cdk-workshop": "bin/cdk-workshop.js"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"cdk": "cdk"
},
"devDependencies": {
"@types/node": "8.10.45",
"typescript": "^3.3.3333",
"ts-node": "^8.1.0",
"aws-cdk": "^1.0.0"
},
"dependencies": {
"@aws-cdk/aws-apigateway": "^1.0.0",
"@aws-cdk/aws-dynamodb": "^1.1.0",
"@aws-cdk/aws-lambda": "^1.0.0",
"@aws-cdk/aws-sns": "^1.0.0",
"@aws-cdk/aws-sns-subscriptions": "^1.0.0",
"@aws-cdk/aws-sqs": "^1.0.0",
"@aws-cdk/core": "^1.0.0"
}
}
The type seems to be specified properly. This seems to be a bug.
I just ran in to this too and solved it. It's because your dependencies aren't aligned. You'll need the same version of all the CDK packages. Sometimes you can get away with it but it looks like there was a core change this time around and the Construct
types now aren't compatible. 1.1.0
vs 1.0.0
"dependencies": {
"@aws-cdk/aws-apigateway": "^1.0.0",
"@aws-cdk/aws-dynamodb": "^1.1.0",
"@aws-cdk/aws-lambda": "^1.0.0",
"@aws-cdk/aws-sns": "^1.0.0",
"@aws-cdk/aws-sns-subscriptions": "^1.0.0",
"@aws-cdk/aws-sqs": "^1.0.0",
"@aws-cdk/core": "^1.0.0"
}
npm update
will take care of it without too much risk
Many thanks @joshrp! Your recommendation fixed it. Turns out I had "npm update" anytime I added a new aws CDK construct.
tried npm update. Still have the same issue
Please make sure all CDK dependencies have exactly the same version.
I am having the same issue. My dependencies are at the same version 1.57.0
"devDependencies": {
"@aws-cdk/assert": "1.57.0",
"@aws-cdk/aws-apigateway": "1.57.0",
"@aws-cdk/aws-certificatemanager": "1.57.0",
"@aws-cdk/aws-iam": "1.57.0",
"@aws-cdk/aws-lambda": "1.57.0",
"@aws-cdk/aws-lambda-nodejs": "^1.57.0",
"@aws-cdk/aws-route53": "1.57.0",
"@aws-cdk/aws-route53-targets": "1.57.0",
"@aws-cdk/aws-s3": "1.57.0",
"@aws-cdk/aws-s3-deployment": "1.57.0",
"@istanbuljs/nyc-config-typescript": "1.0.1",
"@types/chai": "4.2.12",
"@types/js-yaml": "3.12.5",
"@types/lodash.clone": "4.5.6",
"@types/lodash.foreach": "4.5.6",
"@types/lodash.merge": "4.6.6",
"@types/lodash.omit": "4.5.6",
"@types/mocha": "8.0.3",
"@types/mongodb": "3.5.26",
"@types/nanoid": "2.1.0",
"@types/node": "14.6.0",
"@types/node-fetch": "2.5.7",
"@types/sinon": "9.0.4",
"@types/sinon-chai": "3.2.4",
"@typescript-eslint/eslint-plugin": "3.9.1",
"@typescript-eslint/parser": "3.9.1",
"aws-cdk": "1.57.0",
"chai": "4.2.0",
"eslint": "7.7.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-mocha": "8.0.0",
"gts": "2.0.2",
"iam-policy-generator": "1.2.0",
"mocha": "8.1.1",
"nyc": "15.1.0",
"sinon": "9.0.3",
"sinon-chai": "3.5.0",
"source-map-support": "0.5.19",
"ts-clean": "1.0.3",
"ts-node": "^8.10.2",
"typescript": "3.9.7"
},
"dependencies": {
"@aws-cdk/core": "1.57.0",
"ajv": "6.12.4",
"aws-sdk": "2.735.0",
"global": "^4.4.0",
"js-yaml": "3.14.0",
"lodash.clone": "4.5.0",
"lodash.foreach": "4.5.0",
"lodash.merge": "4.6.2",
"lodash.omit": "4.5.0",
"mongodb": "3.6.0",
"nanoid": "3.1.12",
"node-fetch": "2.6.0",
"winston": "3.3.3"
},
I am stuck with no idea how to fix something that this morning was working well.
Your aws-lambda-nodejs
dependecy has a ^
so it uses the latest version.
Most helpful comment
I just ran in to this too and solved it. It's because your dependencies aren't aligned. You'll need the same version of all the CDK packages. Sometimes you can get away with it but it looks like there was a core change this time around and the
Construct
types now aren't compatible.1.1.0
vs1.0.0
npm update
will take care of it without too much risk