TS - Argument of type 'this' is not assignable to parameter of type 'Construct'
See original GitHub issueI have a created a simple Stack that creates a VPC with three simple subnets. though I receive the error Argument of type ‘this’ is not assignable to parameter of type ‘Construct’ . When I use any other resource like S3 or SQS I do not receive the error. As of now, it happens only with VpcNetwork. The typescript code is as follows
cdk version: 0.8.0 (build bb95676) node version: 10.3.0
import * as cdk from '@aws-cdk/cdk'
import { VpcNetwork, SubnetType } from '@aws-cdk/aws-ec2'
class MyStack extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);
new VpcNetwork(this, 'MyVPC', {
cidr: '10.0.0.0/21',
subnetConfiguration: [
{
cidrMask: 24,
name: 'Ingress',
subnetType: SubnetType.Public,
natGateway: true,
},
{
cidrMask: 24,
name: 'Application',
subnetType: SubnetType.Private,
},
{
cidrMask: 28,
name: 'Database',
subnetType: SubnetType.Isolated,
}
],
});
}
}
const app = new cdk.App(process.argv);
new MyStack(app, 'MyStack');
process.stdout.write(app.run());
Issue Analytics
- State:
- Created 5 years ago
- Comments:38 (10 by maintainers)
Top Results From Across the Web
Argument of type 'this' not assignable to parameter 'Construct'
The construct definition looks right to me. That error can occur if the various cdk modules aren't all at the same version; see...
Read more >'this' is not assignable to parameter of type 'Construct' in CDK
I was working on one of my AWS-CDK apps in Typescript when I got squiggly lines under every 'this' in my code.
Read more >Argument of type Not Assignable to type Construct in AWS CDK
The reason we get the "Argument of type is not assignable to parameter of type Construct" error in CDK is because we have...
Read more >How to fix the Error Argument of type 'this' is not ... - WP-kyoto
Failed the npm run build command with the Argument of type 'this' is not assignable to parameter of type 'Construct' error. Why I...
Read more >Argument of type is not assignable to parameter of ... - YouTube
Node js tutorial for Beginners. Argument of type is not assignable to parameter of type typescript | QueryDeepPartialEntity typeorm.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @benswinburne, I believe this is caused by the fact that your
package.json
file has mixed versions of the CDK (@aws-cdk/cdk
is at 0.20.0 and@aws-cdk/aws-*
are at 0.21.0):Try to upgrade everything to 0.21.0 and let us know if the issue still persists.
As mentioned above, this is usually caused by having more than a single version of the CDK in your node modules.
npm install
again