Javascript 应为2个参数,但得到1.ts(2554)index.ts(54112):用于';arg1';没有提供

Javascript 应为2个参数,但得到1.ts(2554)index.ts(54112):用于';arg1';没有提供,javascript,typescript,firebase,firebase-realtime-database,stripe-payments,Javascript,Typescript,Firebase,Firebase Realtime Database,Stripe Payments,并且已经修复了在我的index.ts(typescript)文件中托管代码时弹出的错误。我留下的错误如下: 应为2个参数,但得到1.ts(2554)index.ts(54112):未提供“arg1”的参数 关于这一行(有多个实例,尽管这对解决方案来说并不重要): 如何修复此错误?我遇到过,但它并没有解决我的问题 'use strict'; const functions = require('firebase-functions'); const admin = require('fir

并且已经修复了在我的index.ts(typescript)文件中托管代码时弹出的错误。我留下的错误如下:

应为2个参数,但得到1.ts(2554)index.ts(54112):未提供“arg1”的参数

关于这一行(有多个实例,尽管这对解决方案来说并不重要):

如何修复此错误?我遇到过,但它并没有解决我的问题

 'use strict';

 const functions = require('firebase-functions');
 const admin = require('firebase-admin');
 admin.initializeApp();
 const { Logging } = require('@google-cloud/logging');
 const logging = new Logging({
   projectId: process.env.GCLOUD_PROJECT,
 });
 
 const { Stripe } = require('stripe');
 const stripe = new Stripe(functions.config().stripe.secret, {
   apiVersion: '2020-08-27',
 });
 
 /**
  * When a user is created, create a Stripe customer object for them.
  *
  * @see https://stripe.com/docs/payments/save-and-reuse#web-create-customer
  */
 exports.createStripeCustomer = functions.auth.user().onCreate(async (user: { email: any; uid: any; }) => {
   const customer = await stripe.customers.create({ email: user.email });
   const intent = await stripe.setupIntents.create({
     customer: customer.id,
   });
   await admin.firestore().collection('stripe_customers').doc(user.uid).set({
     customer_id: customer.id,
     setup_secret: intent.client_secret,
   });
   return;
 });
 
 /**
  * When adding the payment method ID on the client,
  * this function is triggered to retrieve the payment method details.
  */
 exports.addPaymentMethodDetails = functions.firestore
   .document('/stripe_customers/{userId}/payment_methods/{pushId}')
   .onCreate(async (snap: { data: () => { (): any; new(): any; id: any; }; ref: { set: (arg0: { error: any; }, arg1: { merge: boolean; } | undefined) => any; parent: { parent: { set: (arg0: { setup_secret: any; }, arg1: { merge: boolean; }) => any; }; }; }; }, context: { params: { userId: any; }; }) => {
     try {
       const paymentMethodId = snap.data().id;
       const paymentMethod = await stripe.paymentMethods.retrieve(
         paymentMethodId
       );
       await snap.ref.set(paymentMethod);
       // Create a new SetupIntent so the customer can add a new method next time.
       const intent = await stripe.setupIntents.create({
         customer: `${paymentMethod.customer}`,
       });
       await snap.ref.parent.parent.set(
         {
           setup_secret: intent.client_secret,
         },
         { merge: true }
       );
       return;
     } catch (error) {
       await snap.ref.set({ error: userFacingMessage(error) }, { merge: true });
       await reportError(error, { user: context.params.userId });
     }
   });
 
 /**
  * When a payment document is written on the client,
  * this function is triggered to create the payment in Stripe.
  *
  * @see https://stripe.com/docs/payments/save-and-reuse#web-create-payment-intent-off-session
  */
 
 // [START chargecustomer]
 
 exports.createStripePayment = functions.firestore
   .document('stripe_customers/{userId}/payments/{pushId}')
   .onCreate(async (snap: { data: () => { amount: any; currency: any; payment_method: any; }; ref: { parent: { parent: { get: () => any; }; }; set: (arg0: { error: any; }, arg1: { merge: boolean; } | undefined) => any; }; }, context: { params: { pushId: any; userId: any; }; }) => {
     const { amount, currency, payment_method } = snap.data();
     try {
       // Look up the Stripe customer id.
       const customer = (await snap.ref.parent.parent.get()).data().customer_id;
       // Create a charge using the pushId as the idempotency key
       // to protect against double charges.
       const idempotencyKey = context.params.pushId;
       const payment = await stripe.paymentIntents.create(
         {
           amount,
           currency,
           customer,
           payment_method,
           off_session: false,
           confirm: true,
           confirmation_method: 'manual',
         },
         { idempotencyKey }
       );
       // If the result is successful, write it back to the database.
       await snap.ref.set(payment);
     } catch (error) {
       // We want to capture errors and render them in a user-friendly way, while
       // still logging an exception with StackDriver
       console.log(error);
       await snap.ref.set({ error: userFacingMessage(error) }, { merge: true });
       await reportError(error, { user: context.params.userId });
     }
   });
 
 // [END chargecustomer]
 
 /**
  * When 3D Secure is performed, we need to reconfirm the payment
  * after authentication has been performed.
  *
  * @see https://stripe.com/docs/payments/accept-a-payment-synchronously#web-confirm-payment
  */
 exports.confirmStripePayment = functions.firestore
   .document('stripe_customers/{userId}/payments/{pushId}')
   .onUpdate(async (change: { after: { data: () => { (): any; new(): any; status: string; id: any; }; ref: { set: (arg0: any) => void; }; }; }, context: any) => {
     if (change.after.data().status === 'requires_confirmation') {
       const payment = await stripe.paymentIntents.confirm(
         change.after.data().id
       );
       change.after.ref.set(payment);
     }
   });
 
 /**
  * When a user deletes their account, clean up after them
  */
 exports.cleanupUser = functions.auth.user().onDelete(async (user: { uid: any; }) => {
   const dbRef = admin.firestore().collection('stripe_customers');
   const customer = (await dbRef.doc(user.uid).get()).data();
   await stripe.customers.del(customer.customer_id);
   // Delete the customers payments & payment methods in firestore.
   const batch = admin.firestore().batch();
   const paymetsMethodsSnapshot = await dbRef
     .doc(user.uid)
     .collection('payment_methods')
     .get();
   paymetsMethodsSnapshot.forEach((snap: { ref: any; }) => batch.delete(snap.ref));
   const paymentsSnapshot = await dbRef
     .doc(user.uid)
     .collection('payments')
     .get();
   paymentsSnapshot.forEach((snap: { ref: any; }) => batch.delete(snap.ref));
 
   await batch.commit();
 
   await dbRef.doc(user.uid).delete();
   return;
 });
 
 /**
  * To keep on top of errors, we should raise a verbose error report with Stackdriver rather
  * than simply relying on console.error. This will calculate users affected + send you email
  * alerts, if you've opted into receiving them.
  */
 
 // [START reporterror]
 
 function reportError(err: { stack: any; }, context = {}) {
   // This is the name of the StackDriver log stream that will receive the log
   // entry. This name can be any valid log stream name, but must contain "err"
   // in order for the error to be picked up by StackDriver Error Reporting.
   const logName = 'errors';
   const log = logging.log(logName);
 
   // https://cloud.google.com/logging/docs/api/ref_v2beta1/rest/v2beta1/MonitoredResource
   const metadata = {
     resource: {
       type: 'cloud_function',
       labels: { function_name: process.env.FUNCTION_NAME },
     },
   };
 
   // https://cloud.google.com/error-reporting/reference/rest/v1beta1/ErrorEvent
   const errorEvent = {
     message: err.stack,
     serviceContext: {
       service: process.env.FUNCTION_NAME,
       resourceType: 'cloud_function',
     },
     context: context,
   };
 
   // Write the error log entry
   return new Promise<void>((resolve, reject) => {
     log.write(log.entry(metadata, errorEvent), (error: any) => {
       if (error) {
         return reject(error);
       }
       return resolve();
     });
   });
 }
 
 // [END reporterror]
 
 /**
  * Sanitize the error message for the user.
  */
 function userFacingMessage(error: { type: any; message: any; }) {
   return error.type
     ? error.message
     : 'An error occurred, developers have been alerted';
 } 
“严格使用”;
const functions=require('firebase-functions');
const admin=require('firebase-admin');
admin.initializeApp();
const{Logging}=require('@googlecloud/Logging');
const logging=新日志记录({
projectd:process.env.GCLOUD_项目,
});
const{Stripe}=require('Stripe');
const stripe=new stripe(functions.config().stripe.secret{
apiVersion:'2020-08-27',
});
/**
*创建用户时,为其创建条带客户对象。
*
*@见https://stripe.com/docs/payments/save-and-reuse#web-创建客户
*/
exports.createStripeCustomer=functions.auth.user().onCreate(异步(用户:{email:any;uid:any;})=>{
const customer=wait stripe.customers.create({email:user.email});
const intent=wait stripe.setupIntents.create({
客户:customer.id,
});
等待admin.firestore().collection('stripe_customers').doc(user.uid).set({
customer\u id:customer.id,
设置密码:intent.client密码,
});
返回;
});
/**
*在客户端上添加付款方式ID时,
*触发此功能以检索付款方式详细信息。
*/
exports.addPaymentMethodDetails=functions.firestore
.document(“/stripe_customers/{userId}/payment_methods/{pushId}”)
.onCreate(async(snap:{data:()=>{():any;new():any;id:any;};ref:{set:{arg0:{error:any;},arg1:{merge:boolean;}未定义)=>any;parent:{parent:{set:{setup_secret any;},arg1:{merge:boolean;}=>any;};};};},上下文:{params:{userId:any{
试一试{
const paymentMethodId=snap.data().id;
const paymentMethod=wait stripe.paymentMethods.retrieve(
paymentMethodId
);
等待快照参考集(付款方式);
//创建新的SetupIntent,以便客户下次可以添加新方法。
const intent=wait stripe.setupIntents.create({
客户:`${paymentMethod.customer}`,
});
等待snap.ref.parent.parent.set(
{
设置密码:intent.client密码,
},
{merge:true}
);
返回;
}捕获(错误){
wait snap.ref.set({error:userFacingMessage(error)},{merge:true});
等待报告错误(错误,{user:context.params.userId});
}
});
/**
*当在客户机上写入付款凭证时,
*触发此功能以创建条带中的付款。
*
*@见https://stripe.com/docs/payments/save-and-reuse#web-创建付款意向关闭会话
*/
//[开始向客户收费]
exports.createStripePayment=functions.firestore
.document('stripe_customers/{userId}/payments/{pushId}')
.onCreate(async(snap:{data:()=>{amount:any;currency:any;payment_method:any;};ref:{parent:{get:{get:()=>any;};};};set:(arg0:{error:any;},arg1:{merge:boolean;}未定义)=>any;},上下文:{params:{pushId:any{
const{amount,currency,payment_method}=snap.data();
试一试{
//查找客户id。
const customer=(wait snap.ref.parent.parent.get()).data().customer\u id;
//使用pushId作为幂等键创建电荷
//防止双重指控。
常量幂等项key=context.params.pushId;
const payment=wait stripe.paymentIntents.create(
{
数量
货币,
顾客
付款方式,
关闭会话:错误,
确认:对,
确认方法:“手动”,
},
{幂等基}
);
//如果结果成功,则将其写回数据库。
等待快照参考集(付款);
}捕获(错误){
//我们希望捕获错误并以用户友好的方式呈现它们,同时
//仍在使用StackDriver记录异常
console.log(错误);
wait snap.ref.set({error:userFacingMessage(error)},{merge:true});
等待报告错误(错误,{user:context.params.userId});
}
});
//[最终客户]
/**
*当执行3D安全时,我们需要再次确认付款
*在执行身份验证之后。
*
*@见https://stripe.com/docs/payments/accept-a-payment-synchronously#web-确认付款
*/
exports.confirmStripePayment=functions.firestore
.document('stripe_customers/{userId}/payments/{pushId}')
.onUpdate(异步(更改:{after:{data:()=>{():any;new():any;状态:string;id:any;};ref:{set:(arg0:any)=>void;};};},上下文:any)=>{
if(change.after.data().status==“需要确认”){
const payment=wait stripe.paymentIntents.confirm(
change.after.data().id
);
参考设置后的变更(付款);
}
});
/**
*当用户删除其帐户时,请在删除后进行清理
*/
exports.cleanupUser=functions.auth.user().onDelete(异步(用户:{uid:any;})=>{
const dbRef=admin.firestore().collection('stripe_customers');
const customer=(wait dbRef.doc(user.uid.get()).data();
等待条带.customers.del(customer.customer\u id);
//删除firestore中的客户付款和付款方式。
const batch=admin.firestore().batch();
const paymetsmethodsnapshot=wait dbRef
.doc(user.uid)
.收款(“付款方式”)
.get();
支付方式
 'use strict';

 const functions = require('firebase-functions');
 const admin = require('firebase-admin');
 admin.initializeApp();
 const { Logging } = require('@google-cloud/logging');
 const logging = new Logging({
   projectId: process.env.GCLOUD_PROJECT,
 });
 
 const { Stripe } = require('stripe');
 const stripe = new Stripe(functions.config().stripe.secret, {
   apiVersion: '2020-08-27',
 });
 
 /**
  * When a user is created, create a Stripe customer object for them.
  *
  * @see https://stripe.com/docs/payments/save-and-reuse#web-create-customer
  */
 exports.createStripeCustomer = functions.auth.user().onCreate(async (user: { email: any; uid: any; }) => {
   const customer = await stripe.customers.create({ email: user.email });
   const intent = await stripe.setupIntents.create({
     customer: customer.id,
   });
   await admin.firestore().collection('stripe_customers').doc(user.uid).set({
     customer_id: customer.id,
     setup_secret: intent.client_secret,
   });
   return;
 });
 
 /**
  * When adding the payment method ID on the client,
  * this function is triggered to retrieve the payment method details.
  */
 exports.addPaymentMethodDetails = functions.firestore
   .document('/stripe_customers/{userId}/payment_methods/{pushId}')
   .onCreate(async (snap: { data: () => { (): any; new(): any; id: any; }; ref: { set: (arg0: { error: any; }, arg1: { merge: boolean; } | undefined) => any; parent: { parent: { set: (arg0: { setup_secret: any; }, arg1: { merge: boolean; }) => any; }; }; }; }, context: { params: { userId: any; }; }) => {
     try {
       const paymentMethodId = snap.data().id;
       const paymentMethod = await stripe.paymentMethods.retrieve(
         paymentMethodId
       );
       await snap.ref.set(paymentMethod);
       // Create a new SetupIntent so the customer can add a new method next time.
       const intent = await stripe.setupIntents.create({
         customer: `${paymentMethod.customer}`,
       });
       await snap.ref.parent.parent.set(
         {
           setup_secret: intent.client_secret,
         },
         { merge: true }
       );
       return;
     } catch (error) {
       await snap.ref.set({ error: userFacingMessage(error) }, { merge: true });
       await reportError(error, { user: context.params.userId });
     }
   });
 
 /**
  * When a payment document is written on the client,
  * this function is triggered to create the payment in Stripe.
  *
  * @see https://stripe.com/docs/payments/save-and-reuse#web-create-payment-intent-off-session
  */
 
 // [START chargecustomer]
 
 exports.createStripePayment = functions.firestore
   .document('stripe_customers/{userId}/payments/{pushId}')
   .onCreate(async (snap: { data: () => { amount: any; currency: any; payment_method: any; }; ref: { parent: { parent: { get: () => any; }; }; set: (arg0: { error: any; }, arg1: { merge: boolean; } | undefined) => any; }; }, context: { params: { pushId: any; userId: any; }; }) => {
     const { amount, currency, payment_method } = snap.data();
     try {
       // Look up the Stripe customer id.
       const customer = (await snap.ref.parent.parent.get()).data().customer_id;
       // Create a charge using the pushId as the idempotency key
       // to protect against double charges.
       const idempotencyKey = context.params.pushId;
       const payment = await stripe.paymentIntents.create(
         {
           amount,
           currency,
           customer,
           payment_method,
           off_session: false,
           confirm: true,
           confirmation_method: 'manual',
         },
         { idempotencyKey }
       );
       // If the result is successful, write it back to the database.
       await snap.ref.set(payment);
     } catch (error) {
       // We want to capture errors and render them in a user-friendly way, while
       // still logging an exception with StackDriver
       console.log(error);
       await snap.ref.set({ error: userFacingMessage(error) }, { merge: true });
       await reportError(error, { user: context.params.userId });
     }
   });
 
 // [END chargecustomer]
 
 /**
  * When 3D Secure is performed, we need to reconfirm the payment
  * after authentication has been performed.
  *
  * @see https://stripe.com/docs/payments/accept-a-payment-synchronously#web-confirm-payment
  */
 exports.confirmStripePayment = functions.firestore
   .document('stripe_customers/{userId}/payments/{pushId}')
   .onUpdate(async (change: { after: { data: () => { (): any; new(): any; status: string; id: any; }; ref: { set: (arg0: any) => void; }; }; }, context: any) => {
     if (change.after.data().status === 'requires_confirmation') {
       const payment = await stripe.paymentIntents.confirm(
         change.after.data().id
       );
       change.after.ref.set(payment);
     }
   });
 
 /**
  * When a user deletes their account, clean up after them
  */
 exports.cleanupUser = functions.auth.user().onDelete(async (user: { uid: any; }) => {
   const dbRef = admin.firestore().collection('stripe_customers');
   const customer = (await dbRef.doc(user.uid).get()).data();
   await stripe.customers.del(customer.customer_id);
   // Delete the customers payments & payment methods in firestore.
   const batch = admin.firestore().batch();
   const paymetsMethodsSnapshot = await dbRef
     .doc(user.uid)
     .collection('payment_methods')
     .get();
   paymetsMethodsSnapshot.forEach((snap: { ref: any; }) => batch.delete(snap.ref));
   const paymentsSnapshot = await dbRef
     .doc(user.uid)
     .collection('payments')
     .get();
   paymentsSnapshot.forEach((snap: { ref: any; }) => batch.delete(snap.ref));
 
   await batch.commit();
 
   await dbRef.doc(user.uid).delete();
   return;
 });
 
 /**
  * To keep on top of errors, we should raise a verbose error report with Stackdriver rather
  * than simply relying on console.error. This will calculate users affected + send you email
  * alerts, if you've opted into receiving them.
  */
 
 // [START reporterror]
 
 function reportError(err: { stack: any; }, context = {}) {
   // This is the name of the StackDriver log stream that will receive the log
   // entry. This name can be any valid log stream name, but must contain "err"
   // in order for the error to be picked up by StackDriver Error Reporting.
   const logName = 'errors';
   const log = logging.log(logName);
 
   // https://cloud.google.com/logging/docs/api/ref_v2beta1/rest/v2beta1/MonitoredResource
   const metadata = {
     resource: {
       type: 'cloud_function',
       labels: { function_name: process.env.FUNCTION_NAME },
     },
   };
 
   // https://cloud.google.com/error-reporting/reference/rest/v1beta1/ErrorEvent
   const errorEvent = {
     message: err.stack,
     serviceContext: {
       service: process.env.FUNCTION_NAME,
       resourceType: 'cloud_function',
     },
     context: context,
   };
 
   // Write the error log entry
   return new Promise<void>((resolve, reject) => {
     log.write(log.entry(metadata, errorEvent), (error: any) => {
       if (error) {
         return reject(error);
       }
       return resolve();
     });
   });
 }
 
 // [END reporterror]
 
 /**
  * Sanitize the error message for the user.
  */
 function userFacingMessage(error: { type: any; message: any; }) {
   return error.type
     ? error.message
     : 'An error occurred, developers have been alerted';
 } 
 snap.ref.set({ error: new Error("Error") }, { merge: true }); // second arg can be merge as true/false or undefined
snap.ref.set({ error: null }, { merge: true }); // second arg can be merge as true/false or undefined

snap.ref.set({ error: null }, undefined);