firebase 错误 TS7006:参数 'snapshot' 隐式具有 'any' 类型
firebase error TS7006: Parameter 'snapshot' implicitly has an 'any' type
我收到以下 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,因此必须为参数 snapshot
和 context
提供类型,如下所示:
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;
});
我收到以下 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,因此必须为参数 snapshot
和 context
提供类型,如下所示:
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;
});