Reputation: 2148
I am currently working on aws cdk, where I am using Typescript for the setup. I have a question, where I have same library but they are referred as not same type.
Compilation Error:
Argument of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput' is not assignable to parameter of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput'.
Types have separate declarations of a private property '_description'.
Argument of type 'CdkCloudFormationAppreciationDashboardStage' is not assignable to parameter of type 'Stage'.
Types of property '_assemblyBuilder' are incompatible.
Type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder' is not assignable to type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder'.
Types have separate declarations of a private property 'artifacts'.ts(2345)
Code:
// This is where we add the application stages
const preprod = new CdkCloudFormationAppreciationDashboardStage(this, 'PreProd', {
env: { account: 'accountnumber', region: 'ap-southeast-1' },
});
// put validations for the stages
const preprodStage = pipeline.addApplicationStage(preprod);
Package.json
"dependencies": {
"@aws-cdk/aws-apigateway": "^1.122.0",
"@aws-cdk/aws-codepipeline": "^1.122.0",
"@aws-cdk/aws-codepipeline-actions": "^1.122.0",
"@aws-cdk/aws-dynamodb": "^1.122.0",
"@aws-cdk/aws-lambda": "^1.122.0",
"@aws-cdk/core": "1.121.0",
"@aws-cdk/pipelines": "^1.122.0",
"@types/aws-lambda": "^8.10.83",
"source-map-support": "^0.5.16"
}
Full Logs:
> [email protected] build
> tsc
lib/cdk-cloud-formation-appreciation-dashboard-pipeline.ts:40:9 - error TS2322: Type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/core/lib/secret-value").SecretValue' is not assignable to type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/core/lib/secret-value").SecretValue'.
Types have separate declarations of a private property 'value'.
40 oauthToken: SecretValue.secretsManager('devhour-backend-git-access-token', {jsonField: 'devhour-backend-git-access-token'}), // this token is stored in Secret Manager
~~~~~~~~~~
node_modules/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.d.ts:118:14
118 readonly oauthToken: SecretValue;
~~~~~~~~~~
The expected type comes from property 'oauthToken' which is declared here on type 'GitHubSourceActionProps'
lib/cdk-cloud-formation-appreciation-dashboard-pipeline.ts:61:53 - error TS2345: Argument of type 'CdkCloudFormationAppreciationDashboardStage' is not assignable to parameter of type 'Stage'.
Types of property '_assemblyBuilder' are incompatible.
Type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder' is not assignable to type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder'.
Types have separate declarations of a private property 'artifacts'.
61 const preprodStage = pipeline.addApplicationStage(preprod);
~~~~~~~
lib/cdk-cloud-formation-appreciation-dashboard-pipeline.ts:68:42 - error TS2345: Argument of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput' is not assignable to parameter of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput'.
Types have separate declarations of a private property '_description'.
68 ENDPOINT_URL: pipeline.stackOutput(preprod.urlOutput),
~~~~~~~~~~~~~~~~~
Upvotes: 1
Views: 1372
Reputation: 1226
You need to make sure that you Aws-cdk packages are all the same version.
Set them all on 1.122.0, don't use ^. Not good practice, things change very ofton in cdk.
"dependencies": {
"@aws-cdk/aws-apigateway": "1.122.0",
"@aws-cdk/aws-codepipeline": "1.122.0",
"@aws-cdk/aws-codepipeline-actions": "1.122.0",
"@aws-cdk/aws-dynamodb": "1.122.0",
"@aws-cdk/aws-lambda": "1.122.0",
"@aws-cdk/core": "1.122.0",
"@aws-cdk/pipelines": "1.122.0",
"@types/aws-lambda": "^8.10.83",
"source-map-support": "^0.5.16"
}
Upvotes: 5