Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

If you get this error, please follow these instructions:

  1. Make sure all CDK modules in your package.json file have the exact same version.
  2. Nuke your local node_modules
  3. Run npm install (or yarn install).

See #542

Reproduction Steps

  1. Utilize any two separate versions of a @aws-cdk/* package. I suspect the source of error is if any two separate files are used when pulling the source or definition of the Construct class. Typically, this has been remarked as an item of two separate @aws-cdk/* package versions in your package.json OR due to a package version range specified in package.json where the team has updated the package version recently. I’ll introduce a new suspected cause in my notes.

  2. Upon running TSC when utilizing constructing any Construct utilizing two separate versions of the Construct file (even if they syntactically 100% the exact same contents), the referenced error will occur: Argument of type 'this' is not assignable to parameter of type 'Construct'.

Note: This refers to the usage of new SomeConstruct(someConstructReference, ...) where SomeConstruct references some different source file for defining Construct vs. what someConstructReference references for its definition of Construct, even if the two source files are 100% identical.


  • CLI Version : 1.30
  • Framework Version: 1.30
  • OS : Windows
  • Language : TypeScript


We had decent luck resolving these issues due to errors relating to mismatched versions. This breaks, however, when utilizing some package depending on CDK as a global since the dependencies of the global (i.e. some different CDK file defining Construct) are not installed into the dependee module (i.e. a file that ultimately depends on some other CDK file defining Construct).

Please see this:

I have an idea to resolve, will post a follow-up if this yields luck. Suggest dropping a note into your docs regarding any team trying to build a global module that depends on CDK (where dependees also depend on CDK in some way).

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

hoegertncommented, May 28, 2020

@maxpaj you should always pin your CDK versions to exactly one version and not use the caret ^.

eladbcommented, Apr 9, 2020

Thanks for reporting this! We are well aware that this is still a major issue in consuming the CDK and publishing modules, and working hard to solve it.


Read more comments on GitHub >

github_iconTop 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 >
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 >
TS - Argument of type 'this' is not assignable to parameter of ...
I have a created a simple Stack that creates a VPC with three simple subnets. though I receive the error Argument of type...
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 >
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found