fix: tighten v2 wrapper event typing#316
Draft
CorieW wants to merge 3 commits into
Draft
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the WrappedV2Function type in src/v2.ts to use a new WrappedV2CloudEventPartial type, ensuring that V2 wrappers accept CloudEvent partials rather than raw event data. In the test suite, a helper function assertWrappedV2FunctionTypes was added to assert these types. However, this helper function is currently unused, resulting in dead code. It is recommended to wrap these type assertions directly in a standard Mocha it block to ensure they are executed and to prevent potential linter or compiler warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Touches on #205
WrappedV2Functionso wrapper arguments must keep CloudEvent shape.dataoverrides for generated mock payloads and JSON test data.wrapped({ data: change })is valid while rawwrapped(change)is rejected.Why
V2 wrapped functions accept CloudEvent partials, but the previous
DeepPartial<T | object>type let callers pass raw event data. For Firestore change triggers, that makeswrapped(change)compile even though runtime code readscloudEventPartial.dataand falls back to example data.Validation
npm run pretestnpm run lintenv -u GOOGLE_APPLICATION_CREDENTIALS npm test