Javascript 为什么可以';我不能将此代码部署到firebase函数吗?我不知道';我不理解这个错误

Javascript 为什么可以';我不能将此代码部署到firebase函数吗?我不知道';我不理解这个错误,javascript,firebase,firebase-realtime-database,google-cloud-functions,Javascript,Firebase,Firebase Realtime Database,Google Cloud Functions,我不熟悉firebase功能-显然-我正在尝试测试创建时数据库特定路径中的电子邮件是否被帐户使用,如果未被使用,则相应地更改该数据库值。代码如下: exports.checkEmail = functions.database.ref('/checkEmailExistance') .onCreate((snapshot, context) => { // Grab the current value of what was written to the Realtim

我不熟悉firebase功能-显然-我正在尝试测试创建时数据库特定路径中的电子邮件是否被帐户使用,如果未被使用,则相应地更改该数据库值。代码如下:

exports.checkEmail = functions.database.ref('/checkEmailExistance')
    .onCreate((snapshot, context) => {
      // Grab the current value of what was written to the Realtime Database.
      const email = snapshot.val();
      console.log('Email:', email, context.params.pushId);
      admin.auth().getUserByEmail(email)
      .then(snapshot => {
          const data = snapshot.toJSON()

          return admin.database().ref('checkEmailExistance').child(email).set("Nope") 
      })
});
错误是:

ERROR: /Users/nathan/Documents/FirebaseFunctionsClipify/functions/src/index.ts:41:7 - Promises must be handled appropriately
ERROR: /Users/nathan/Documents/FirebaseFunctionsClipify/functions/src/index.ts:42:13 - Shadowed name: 'snapshot'

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ lint: `tslint --project tsconfig.json`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nathan/.npm/_logs/2019-04-25T16_21_29_696Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code2
更新:

我更改了代码,因此不应再次产生错误,但仍然得到相同的错误:

exports.checkEmail = functions.database.ref('/checkEmailExistance')
    .onCreate((snapshot, context) => {
      // Grab the current value of what was written to the Realtime Database.
      const email = snapshot.val();
      console.log('Email:', email, context.params.pushId);
      return admin.auth().getUserByEmail(email)
      .then(snap => {
          const data = snap.toJSON()

          return admin.database().ref('checkEmailExistance').child(email).set("Nope") 
      })
    });

第二个错误告诉您重新定义了一个名为snapshot的现有变量。请注意,快照是在函数回调的顶层定义的,然后再次在
回调中定义。第二个实例是“隐藏”第一个实例,这是代码中的一个潜在错误。只需将第二个变量命名为不同的名称

第一个lint错误告诉您代码中有一个未处理的承诺。您可以通过从
admin.auth().getUserByEmail()返回承诺来修复此问题。然后(…)


我把密码改成了你的答案,但还是有同样的错误。
  return admin.auth().getUserByEmail(email)
  .then(snap => {
      const data = snap.toJSON()

      return admin.database().ref('checkEmailExistance').child(email).set("Nope") 
  })