Javascript 角度订阅和条带订阅保存付款详细信息并创建订阅
我一直在关注这个问题。我很难将JavaScript代码转换为TypeScript。在stripe文档中,它们将对象传递给createPaymentMethod函数。在Angular中,它不允许传递,因为对象必须有3个属性,但在文档中,它们只传递一个属性 错误:Javascript 角度订阅和条带订阅保存付款详细信息并创建订阅,javascript,angular,typescript,stripe-payments,Javascript,Angular,Typescript,Stripe Payments,我一直在关注这个问题。我很难将JavaScript代码转换为TypeScript。在stripe文档中,它们将对象传递给createPaymentMethod函数。在Angular中,它不允许传递,因为对象必须有3个属性,但在文档中,它们只传递一个属性 错误: error TS2345: Argument of type '{ card: any; }' is not assignable to parameter of type '{ card: any; isPaymentRetry: an
error TS2345: Argument of type '{ card: any; }' is not assignable to parameter of type '{ card: any; isPaymentRetry: any; invoiceId: any; }'.
Type '{ card: any; }' is missing the following properties from type '{ card: any; isPaymentRetry: any; invoiceId: any; }': isPaymentRetry, invoiceId
代码:
问题在于线路
else {
this.createPaymentMethod({ card});
}
这里您正在使用一个仅包含卡的对象调用this.createPaymentMethod
,但方法签名需要卡,isPaymentRetry
和发票ID
:
createPaymentMethod({ card, isPaymentRetry, invoiceId}) {
您需要将此更改为传入缺少参数的值,或者指定isPaymentRetry
和invoiceId
是可选的,例如:
createPaymentMethod({ card: any, isPaymentRetry?: bool, invoiceId?: string }) {
createPaymentMethod({ card: any, isPaymentRetry?: bool, invoiceId?: string }) {