我有这样的测试代码:
const ddb = new AWS.DynamoDB();
const q = sandbox.stub(ddb, "putItem");
const out: PromiseResult<PutItemOutput, AWSError> = { Attributes: {}, $response: null };
const queryParam = {
TableName: "TEST",
Item: {id: S: "123" },
ConditionExpression: "attribute_not_exists(modified) OR modified <= :m",
ExpressionAttributeValues: {
":m": {S: "2019-01-01"}
}
};
q.withArgs(queryParam).returns({
promise: () => (Promise.resolve(out))
});
但是我有一个错误:
error TS2322: Type 'null' is not assignable to type 'Response<PutItemOutput, AWSError>'
和error TS2345: Argument of type '{ promise: () => Promise<PromiseResult<PutItemOutput, AWSError>>; }' is not assignable to parameter of type 'Request<PutItemOutput, AWSError>'
我的代码有什么问题?如何解决?