gpt4 book ai didi

javascript - 火力地堡错误 TS7006 : Parameter 'snapshot' implicitly has an 'any' type

转载 作者:行者123 更新时间:2023-11-30 11:00:54 25 4
gpt4 key购买 nike

我收到以下 lint 错误:

error TS7006: Parameter 'snapshot' implicitly has an 'any' type.

关于以下 Firebase 云功能:

exports.createTeamMember = functions.firestore
.document(`teamProfile/{teamId}/teamMemberList/{newUserId}`)
.onCreate(async (snapshot, context) => {
const id: string = snapshot.data().id;
const email: string = snapshot.data().email;
const teamId: string = snapshot.data().teamId;
});

最佳答案

由于您使用的是 TSLint,因此必须为参数 snapshotcontext 提供类型,如下所示:

import * as admin from 'firebase-admin';
import { EventContext } from 'firebase-functions';

exports.createTeamMember = functions.firestore
.document(`teamProfile/{teamId}/teamMemberList/{newUserId}`)
.onCreate(async (snapshot: admin.firestore.DocumentSnapshot, context: EventContext) => {
const id: string = snapshot.data().id;
const email: string = snapshot.data().email;
const teamId: string = snapshot.data().teamId;
});

关于javascript - 火力地堡错误 TS7006 : Parameter 'snapshot' implicitly has an 'any' type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57771948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com