aws-sdk-client-mock
aws-sdk-client-mock copied to clipboard
Types is not working for aws-sdk 3.362.0
Checklist
- [X] I have read Caveats documentation and didn't find a solution for this problem there.
Bug description
Hello, have a PNPM monorepo and one of package have dependencies like
"dependencies": {
"@aws-sdk/client-ssm": "3.362.0"
},
"devDependencies": {
"@smithy/types": "1.1.0",
"aws-sdk-client-mock": "^2.2.0"
},
Received an error like
Reproduction
import { SSM } from '@aws-sdk/client-ssm';
import { mockClient } from 'aws-sdk-client-mock';
const ssmClientMock = mockClient(SSM);
Environment
- Node version: v18.18.2
- Testing lib and version: Jest v29.7.0
- Typescript version: v5.0.x
- AWS SDK v3 Client mock version: v2.2.0
- AWS JS SDK libs and versions: @aws-sdk/client-ssm v3.362.0
I'm getting the same on the latest versions of aws sdk and aws-sdk-client-mock.
It seems to be coming from @smithy/types. Not sure how to resolve just yet.
https://github.com/aws/aws-sdk-js-v3/issues/5252
I think I resolved it by making sure all @aws-sdk
packages were up to date. I had the one I was working with (@aws-sdk/client-s3) updated but I had another one that was added for a different area of the project that had an older version (@aws-sdk/util-stream-node)
The Client
type in the AWS SDK up to v3.363.0 was defined in the @aws-sdk/types
package. From v3.363.0, the Client
type is in @smithy/types
. So having installed v3.362.0 and @smithy/types
most likely leads to type conflicts.
Updating all AWS SDK packages to the same version and making sure only one version of @aws-sdk/types
or @smithy/types
is installed usually solves problems. See README and #197.