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,
After upgrading
@aws-sdk/*
package(s) to a newer version, themockClient()
function throws type errors similar to this:In 99% of cases, this is not a problem with type incompatibility between
@aws-sdk/*
andaws-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:
@aws-sdk/*
packages point to the same version,@aws-sdk/*
packages frompackage.json
, runnpm install
/pnpm install
/yarn install
, restore@aws-sdk/*
packages inpackage.json
, and run install again,@smithy/types
to your dev dependencies in the latest version,@smithy/types
version with npm overrides, pnpm overrides, or yarn resolutions,npm ls @smithy/types
/pnpm why @smithy/types
/yarn why @smithy/types
.