Skip to content

In Typescript, SQS.CreateQueueCommand requires all queue attributes due to Attributes having type Record<QueueAttributeName, string> #5387

Closed
@suchanpark-koioi

Description

@suchanpark-koioi

Checkboxes for prior research

Describe the bug

A simple code below:

const sqsClient = new SQSClient();
const createCommandOutput = await sqsClient.send(
  new CreateQueueCommand({
    QueueName: queueName,
    Attributes: {
      RedrivePolicy: JSON.stringify({
        maxReceiveCount: '5',
      }),
    },
  }),
);

gives TypeScript error as follows:

TS2740: Type  { RedrivePolicy: string; }  is missing the following properties from type  Record<QueueAttributeName, string> :
All, ApproximateNumberOfMessages, ApproximateNumberOfMessagesDelayed, ApproximateNumberOfMessagesNotVisible
, and  17  more.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

18.15.0

Reproduction Steps

import {
  CreateQueueCommand,
  SQSClient,
} from '@aws-sdk/client-sqs';

const sqsClient = new SQSClient();
const createCommandOutput = await sqsClient.send(
  new CreateQueueCommand({
    QueueName: 'anyname',
    Attributes: {
      RedrivePolicy: JSON.stringify({
        maxReceiveCount: '5',
      }),
    },
  }),
);

Create a typescript file with the content above and run tsc. Use @aws-sdk/client-sqs with version >=3.430.0.

Observed Behavior

Typescript error that says as below:

TS2740: Type  { RedrivePolicy: string; }  is missing the following properties from type  Record<QueueAttributeName, string> :
All, ApproximateNumberOfMessages, ApproximateNumberOfMessagesDelayed, ApproximateNumberOfMessagesNotVisible
, and  17  more.

Expected Behavior

This code should compile with Typescript.

Specifiying all the parameters is not required, it can be seen as, for example, here: https://docs.aws.amazon.com/cli/latest/reference/sqs/create-queue.html

This code didn't produce Typescript Error at least until 3.421.0.

Possible Solution

Maybe change the type of Attributes into something like Partial< Record<QueueAttributeName, string> >?

Additional Information/Context

Typescript 5.2.2

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.p1This is a high priority issuepending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.workaround-availableThis issue has a work around available.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions