Closed 1oglop1 closed 1 year ago
Looking into it. Curious, what TS version are you using ?
4.9.5, I could try with a different version
Interesting, I upgraded to 5.1.6 and the type error is gone 🎉 !
I have a bit OT question.
I have a table with the GSI attribute sent
which I'd like to be a boolean
however when defining the table I can only use S
then my type looks like this
interface PaymentNotificationDB {
pk: string;
sk: string;
sent: boolean;
}
which works with const putPaymentNotification = TypeSafePutDocumentCommand<PaymentNotificationDB>();
but then
const putCmd = new putPaymentNotification({
TableName,
Item: s,
});
const putResult = await documentClient.send(putCmd);
returns ValidationException: Invalid attribute value type
. Am I missing something or do the attributes which are indexes must be a string?
Interesting, I upgraded to 5.1.6 and the type error is gone 🎉 !
Yay!
returns ValidationException: Invalid attribute value type. Am I missing something or do the attributes which are indexes must be a string?
It looks like the table definition defines sent
as a S
.
AttributeDefinitions: [
{ AttributeName: "pk", AttributeType: "S" },
{ AttributeName: "sk", AttributeType: "S" },
{ AttributeName: "sent", AttributeType: "S" },
],
I assume you're doing this because PK/SK only supports S/B/N. The reason for your failure is that you are trying to store a JS boolean
in a S
field. The SDK will convert that boolean
into a { BOOL: true|false}
which does not comply with your defined schema.
It is not possible to use a BOOL
field as a PK/SK in a GSI. You will have to convert this to a string for it to work.
typesafe-dynamodb has no runtime component (it is types only) so if you're getting a runtime error then it is the service + SDK that is causing the problem
Thanks for the help. I think that we can close this as no issue. Unless you have time to test the problem with the version of TS I mentioned earlier.
Hi I get the type error with the following code
click to expand Error Log
``` TSError: ⨯ Unable to compile TypeScript: src/post.spec.ts(134,46): error TS2345: Argument of type 'Command