Javascript Firebase函数类型脚本
我有这个功能,我已经写过的基础上 但是,我的IDE VCode中有一个错误 如有任何建议,将不胜感激Javascript Firebase函数类型脚本,javascript,typescript,firebase,google-cloud-functions,Javascript,Typescript,Firebase,Google Cloud Functions,我有这个功能,我已经写过的基础上 但是,我的IDE VCode中有一个错误 如有任何建议,将不胜感激 [ts] Argument of type '(snap: any, context: any) => Promise<void>' is not assignable to parameter of type '(event: Event<DeltaDocumentSnapshot>) => any'. 我的代码-键入脚本 exports.createU
[ts] Argument of type '(snap: any, context: any) => Promise<void>' is not
assignable to parameter of type '(event: Event<DeltaDocumentSnapshot>) => any'.
我的代码-键入脚本
exports.createUser = functions.firestore
.document('users/{userId}')
.onCreate((snap, context) => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
const newValue = snap.data();
// access a particular field as you would any JS property
const name = newValue.name;
// perform desired operations ...
});
import * as functions from 'firebase-functions';
import { db } from './config';
import { createCustomer } from './helpers';
export const createStripeCustomer = functions.firestore.document('users/{userId}').onCreate((snap, context) => {
const user = snap.data();
const userRef = db.collection('users').doc(user.uid);
if (user.newCustomer === true) {
return createCustomer(user)
.then(customer => {
// Get a new write batch
const batch = db.batch();
// Update the User Profile with Stripe Customer Id
batch.set(userRef, { accountId: customer.id }, { merge: true });
// Create Organization
const orgRef = db.collection('miCustomers').doc(customer.id);
batch.set(orgRef, {
id: customer.id,
accountId: customer.id,
name: customer.email,
email: customer.email
});
// Commit the batch
return batch.commit().then(function() {
// ...
});
})
.catch(console.log);
} else {
return null;
}
});
您是如何创建项目的?您使用的是什么版本的firebase函数库?@DougStevenson谢谢,我使用的是“firebase管理”:“~5.12.1”,“firebase函数”:“^1.0.3”。但是我今天回来了,错误消失了,我什么也没做。这可能是因为你的软件包有问题,有时VScode在你重新启动之前不会接收更新