Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to types not compatible with @aws-sdk/* version 3.xxx.x #197

Open
m-radzikowski opened this issue Dec 31, 2023 · 0 comments
Open

Comments

@m-radzikowski
Copy link
Owner

After upgrading @aws-sdk/* package(s) to a newer version, the mockClient() function throws type errors similar to this:

TS2345: Argument of type 'typeof DynamoDBDocumentClient' is not assignable to parameter of type 'InstanceOrClassType<Client<ServiceInputTypes, MetadataBearer, any>>'.
  Type 'typeof DynamoDBDocumentClient' is not assignable to type 'ClassType<Client<ServiceInputTypes, MetadataBearer, any>>'.
    The types of 'prototype.middlewareStack.concat' are incompatible between these types.
      Type '<InputType extends ServiceInputTypes, OutputType extends ServiceOutputTypes>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<...>' is not assignable to type '<InputType extends ServiceInputTypes, OutputType extends MetadataBearer>(from: MiddlewareStack<InputType, OutputType>) => MiddlewareStack<InputType, OutputType>'.
        Types of parameters 'from' and 'from' are incompatible.
          Property 'identify' is missing in type 'MiddlewareStack<InputType, OutputType>' but required in type 'MiddlewareStack<InputType, ServiceOutputTypes>'.

In 99% of cases, this is not a problem with type incompatibility between @aws-sdk/* and aws-sdk-client-mock, but a resolut of having multiple versions of @smithy/types package installed.

Follow those steps to solve it

Go through the steps until one works:

Run npm ls @smithy/types / pnpm why @smithy/types / yarn why @smithy/types
and check if you have more than one version of the package installed.

Go through the steps until one works:

  • make sure all your @aws-sdk/* packages point to the same version,
  • remove all @aws-sdk/* packages from package.json, run npm install / pnpm install / yarn install, restore @aws-sdk/* packages in package.json, and run install again,
  • add @smithy/types to your dev dependencies in the latest version,
  • force using single @smithy/types version with npm overrides, pnpm overrides, or yarn resolutions,
  • if nothing else helped, open an issue including the output of npm ls @smithy/types / pnpm why @smithy/types / yarn why @smithy/types.
@m-radzikowski m-radzikowski pinned this issue Dec 31, 2023
Repository owner locked and limited conversation to collaborators Dec 31, 2023
@m-radzikowski m-radzikowski changed the title Types are not compatible with @aws-sdk/* version 3.xxx.x Solution to types not compatible with @aws-sdk/* version 3.xxx.x Dec 31, 2023
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

1 participant