aws-sdk-js-v3: Bad types after smithy upgrade

Checkboxes for prior research

Describe the bug

Here are 2 examples of some issues I am experiencing with types with 3.363.0

I scanned through https://github.com/aws/aws-sdk-js-v3/blob/main/CHANGELOG.md and can’t find anything that makes these seem like intentional changes, sorry if this is all a bit vague but maybe someone with more information can ask more pointed questions/add something that helps.

3.362.0 is all good, 3.363.0 has all sorts of issues. The only change that seems relevant to me is https://github.com/aws/aws-sdk-js-v3/pull/4873

Issues I see with @aws-sdk/s3-request-presigner:

Argument of type 'S3' is not assignable to parameter of type 'Client<any, ServiceInputTypes, MetadataBearer, any>'.
  The types of 'middlewareStack.add' are incompatible between these types.
    Type '{ (middleware: InitializeMiddleware<ServiceInputTypes, ServiceOutputTypes>, options?: (InitializeHandlerOptions & AbsoluteLocation) | undefined): void; (middleware: SerializeMiddleware<...>, options: SerializeHandlerOptions & AbsoluteLocation): void; (middleware: BuildMiddleware<...>, options: BuildHandlerOptions & ...' is not assignable to type '{ (middleware: InitializeMiddleware<ServiceInputTypes, MetadataBearer>, options?: (InitializeHandlerOptions & AbsoluteLocation) | undefined): void; (middleware: SerializeMiddleware<...>, options: SerializeHandlerOptions & AbsoluteLocation): void; (middleware: BuildMiddleware<...>, options: BuildHandlerOptions & Abso...'.
      Types of parameters 'middleware' and 'middleware' are incompatible.
        Types of parameters 'next' and 'next' are incompatible.
          Type 'InitializeHandler<ServiceInputTypes, ServiceOutputTypes>' is not assignable to type 'InitializeHandler<ServiceInputTypes, MetadataBearer>'.
            Type 'ServiceOutputTypes' is not assignable to type 'MetadataBearer'.ts(2345)

image

Issues I see with @aws-sdk/client-s3:

Property 'Body' does not exist on type 'GetObjectCommandOutput'.ts(2339)

image

SDK version number

@aws-sdk/s3-request-presigner@3.363.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node v18.16.0

Reproduction Steps

Code snippets in screenshots are one example

Observed Behavior

Lots of typescript errors and weirdness with 3.363.0

Expected Behavior

Types work correctly like in 3.362.0

Possible Solution

No response

Additional Information/Context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 25
  • Comments: 26 (4 by maintainers)

Most upvoted comments

Deleting my lock file and reinstalling seems to resolve the issues…

Hi everyone on the thread. It seems like there is a mix of people that solved this by deleting the lock file and npm installing the latest versions of the SDK. For others it was to install a newer version of smithy types directly, for others its a different issue altogether.

Because this was not reproducible, and people are chiming in with different reasoning, we are not able to make actionable suggestions. I ask that if you are still affected to do the following:

  1. Delete the lock file and re-install your dependencies - preferably use the latest version
  2. If the issue persists please open a new issue, and provide a small github repository that we can clone and test locally ourselves to better help you.

Thanks, Ran~

issue went away after forcing @smithy/types : 2.2.2 s3 was using 2.0.2 according to lock file

It’s fairly irresponsible to recommend deleting a lock file to correct a single dependency issue. they’re not supposed to be superfluous like that.

it happened to me in the newest version 3.465.0

it thinks it should be “new S3Client([{ region: ‘us-east1’ }])”, which throws region not found error instead of “new S3Client({ region: ‘us-east1’ })” which is correct but the typescript doesn’t accept

i tried to delete node_modules and the lock file like suggested, and also install the latest smithy/types 2.6.0 instead of relying on the dependency and it didn’t help

reverting to “@aws-sdk/client-s3”: “3.13.1” helped.