Closed
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
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