AWSMock.mock("SQS", "receiveMessage", {
Messages: [
{
MessageId: "abcd",
Body: "sample body",
},
],
});
In the example above, how to type the object as a ReceiveMessageResult instance?
I cannot type the AWSMock.mock() method as this is a generic method in a 3rd party mocking library.
️ This doesn't work, as it wouldn't catch any type error (for example any missing field would not trigger an error):
AWSMock.mock("SQS", "receiveMessage", {
Messages: [
{
MessageId: "abcd",
Body: "sample body",
},
],
} as ReceiveMessageResult);
️ This could work, but I don't want to go through an extra variable:
const response: ReceiveMessageResult = {
Messages: [
{
MessageId: "abcd",
Body: "sample body",
},
],
};
AWSMock.mock("SQS", "receiveMessage", response);
Is there any way to type a object on the fly?