Update type declaration of captureAWSv3Client to fix TS errors #575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #439, #547
Description of changes: This PR updates the TypeScript definition of
captureAWSv3Client
to fix errors reported by customers in the issues above:This error was due to an incompatibility between the
middlewareStack
types used by theClient
type defined in the@aws-sdk/types
package. The root cause behind this incompatibility is conflicting nested versions of the@aws-sdk/types
package being used in this repo. These versions can be verified using the following command:Which currently produces the following output:
To fix the error reported above, a minimal type can be used to extract the
middlewareStack
from the AWS client being passed intocaptureAWSv3client
. This will ensure thatmiddlewareStack.use
andmiddlewareStack.remove
exist on the client (which are the necessary components for the implementation) while avoiding the minor version incompatibilities between their types.This change was tested using the following sample app:
Prior to the changes, the
const instrumentedClient = captureAWSv3Client(dynamoDBClient, segment)
generated the error reported above. The error no longer persists after these changes.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.