我有:
let resItem: Schema
resItem = await dynamoClient.get({
TableName,
Key: {
uuid: request.body.uuid
}
}).promise()
但我得到:
Type 'PromiseResult<GetItemOutput, AWSError>' is missing the following properties from type 'Schema': uuid, topics, phoneNumber, timezonets(2739)
最佳答案
如果您检查the definition of GetItemOutput和 the definition of PromiseResult您将看到 Promise 返回一个 {Item, ConsumedCapacity, $response}
的对象,但不仅仅是结果。因此,我认为您应该使用 PromiseResult
作为类型,并使用 Item
属性作为结果。
关于node.js - 如何使用 TypeScript 定义 DynamoDB get 的返回类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62285490/