You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add import { onDocumentWritten, Change, FirestoreEvent } from 'firebase-functions/v2/firestore'; to a file
[REQUIRED] Expected behavior
The function should work as described in the documentation.
[REQUIRED] Actual behavior
After building or serving the functions, I encountered an error message that says:
Module '"firebase-functions/v2/firestore"' declares 'Change' locally, but it is not exported.
node_modules/firebase-functions/lib/v2/providers/firestore.d.ts:3:10
3 import { Change, CloudEvent, CloudFunction } from "../core";
~~~~~~
'Change' is declared here.
To resolve this error, I removed Change from firebase-functions/v2/firestore and instead used import { Change } from 'firebase-functions'.
However, even after this modification, the function still did not work as stated in the documentation. I had to replace event.data.change.before and event.data.change.after with event.data.before and event.data.after, respectively, to get the desired results.
Were you able to successfully deploy your functions?
To compile the functions successfully, I had to make two changes:
remove Change from firebase-functions/v2/firestore and import it using import { Change } from 'firebase-functions';
use event.data.before and event.data.after instead of event.data.change.before or event.data.change.after
After these changes, Typescript stopped complaining. However, even after making these changes, the emulator did not recognize the function, and as a result, it did not work.
The text was updated successfully, but these errors were encountered:
@service-paradis Added export of the Change interface and we'll release a patch release soon! The docs should also get an update to remove change from the event path. Thanks!
Related issues
None
[REQUIRED] Version info
node: 18.13.0
firebase-functions: 4.3.0
firebase-tools: 11.27.0
firebase-admin: 11.6.0
[REQUIRED] Test case
Please follow the instructions provided in the official Firebase documentation at https://firebase.google.com/docs/functions/beta/firestore-events?hl=fr#trigger_a_function_for_all_changes_to_a_document.
[REQUIRED] Steps to reproduce
import { onDocumentWritten, Change, FirestoreEvent } from 'firebase-functions/v2/firestore';
to a file[REQUIRED] Expected behavior
The function should work as described in the documentation.
[REQUIRED] Actual behavior
After building or serving the functions, I encountered an error message that says:
To resolve this error, I removed
Change
fromfirebase-functions/v2/firestore
and instead usedimport { Change } from 'firebase-functions'
.However, even after this modification, the function still did not work as stated in the documentation. I had to replace
event.data.change.before
andevent.data.change.after
withevent.data.before
andevent.data.after
, respectively, to get the desired results.Were you able to successfully deploy your functions?
To compile the functions successfully, I had to make two changes:
Change
fromfirebase-functions/v2/firestore
and import it usingimport { Change } from 'firebase-functions';
event.data.before
andevent.data.after
instead ofevent.data.change.before
orevent.data.change.after
After these changes, Typescript stopped complaining. However, even after making these changes, the emulator did not recognize the function, and as a result, it did not work.
The text was updated successfully, but these errors were encountered: