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

TypeScript error for seemingly legitimate use of the SDK. #816

Closed
richgarner-nsw-gov opened this issue Jul 7, 2023 · 2 comments
Closed
Labels
response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days.

Comments

@richgarner-nsw-gov
Copy link

richgarner-nsw-gov commented Jul 7, 2023

When I try to use the SendMessageBatchCommand command in the send function of the SQS client I get this type error.

Example code:

import {
  SQSClient,
  SendMessageBatchCommand,
  SendMessageBatchCommandOutput,
} from "@aws-sdk/client-sqs";

export const sqsClient = new SQSClient({});

...

    const command = new SendMessageBatchCommand({
        QueueUrl: "QUEUE_URL",
        Entries: entries.map(([messageId, message]) => {
           ...
        }),
      });
      const commandOutput = await sqsClient.send(command);

I get the type error:

image
Argument of type 'SendMessageBatchCommand' is not assignable to parameter of type 'Command<ServiceInputTypes, SendMessageBatchCommandInput, ServiceOutputTypes, SendMessageBatchCommandOutput, SmithyResolvedConfiguration<...>>'.
  Types of property 'resolveMiddleware' are incompatible.
    Type '(clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: SQSClientResolvedConfig, options?: HttpHandlerOptions | undefined) => Handler<...>' is not assignable to type '(stack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: SmithyResolvedConfiguration<HttpHandlerOptions>, options: any) => Handler<...>'.
      Types of parameters 'clientStack' and 'stack' are incompatible.
        Type 'import("/Users/richard.garner/git/my-project/node_modules/@smithy/signature-v4/node_modules/@smithy/types/dist-types/middleware").MiddlewareStack<import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceInputTypes, import("/Users/ri...' is not assignable to type 'import("/Users/richard.garner/git/my-project/node_modules/@smithy/types/dist-types/middleware").MiddlewareStack<import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceInputTypes, import("/Users/richard.garner/git/hazardwatch/packa...'.
          Types of property 'concat' are incompatible.
            Type '<InputType extends import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceInputTypes, OutputType extends import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceOutputTypes>(from...' is not assignable to type '<InputType extends import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceInputTypes, OutputType extends import("/Users/richard.garner/git/my-project/node_modules/@aws-sdk/client-sqs/dist-types/SQSClient").ServiceOutputTypes>(from...'. Two different types with this name exist, but they are unrelated.
              Types of parameters 'from' and 'from' are incompatible.
                Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, ServiceOutputTypes>'.
                  Types of property 'addRelativeTo' are incompatible.
                    Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, ServiceOutputTypes>, options: RelativeMiddlewareOptions) => void'.
                      Types of parameters 'middleware' and 'middleware' are incompatible.
                        Type 'MiddlewareType<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                          Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
                            Type 'InitializeMiddleware<InputType, ServiceOutputTypes>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
                              Call signature return types 'InitializeHandler<InputType, ServiceOutputTypes>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
                                Type 'Promise<InitializeHandlerOutput<ServiceOutputTypes>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
                                  Type 'InitializeHandlerOutput<ServiceOutputTypes>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
                                    Types of property 'output' are incompatible.
                                      Type 'ServiceOutputTypes' is not assignable to type 'OutputType'.
                                        'ServiceOutputTypes' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'ServiceOutputTypes'.
                                          Type 'SendMessageBatchCommandOutput' is not assignable to type 'OutputType'.
                                            'SendMessageBatchCommandOutput' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'ServiceOutputTypes'.ts(2345)
@richgarner-nsw-gov
Copy link
Author

On further investigation it seems to be resolved by rolling back @aws-sdk/client-sqs from 3.363.0 to 3.362.0.

@kuhe
Copy link
Contributor

kuhe commented Jul 26, 2023

check your lockfile for multiple installed versions of @smithy/types. Upgrade the dependency such that your lockfile only contains one version of it, and that should fix the compilation error.

@kuhe kuhe added the response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. label Sep 13, 2023
@syall syall closed this as completed Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days.
Projects
None yet
Development

No branches or pull requests

3 participants