-
Notifications
You must be signed in to change notification settings - Fork 212
Make event params strongly typed #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4042731
to
801a7b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coolest PR of the year
spec/common/params.spec.ts
Outdated
it('falls back to Record<string, string> without better type info', () => { | ||
expectType<ParamsOf<string>>({} as Record<string, string>); | ||
}); | ||
|
||
it('is the empty object when there are no params', () => { | ||
expectType<ParamsOf<string>>({} as Record<string, never>); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: How does these two test case (which look identical to me) both pass 🤔 ?
ParamsOf<string>
is both Record<string, string>
and Record<string, never>
?
Integration test caught some bugs! 1. From #1155 - Some internal type must be exposed - otherwise compiling user projects fails w/ error message like below: ``` Error: node_modules/firebase-functions/lib/common/params.d.ts(10,13): error TS2314: Generic type 'Extract' requires 2 type argument(s). Error: node_modules/firebase-functions/lib/common/params.d.ts(10,21): error TS2304: Cannot find name 'Split'. Error: node_modules/firebase-functions/lib/common/params.d.ts(10,27): error TS2304: Cannot find name 'NullSafe'. ``` 2. From #1181 - There is no way to call private callable functions since GCF requrie GCP identity token as authorization header while callable function requires Firebase auth tokens. Disabling those test cases in the integration test until we can mint a GCP project w/ permission to create public functions.
Implements go/cf3-typed-params.
WIP: currently only common and v2 are implemented.
Had to update
prettier
to the next major version so it could read TS 4.1 features without erroring out. I created #1160 as a base for this change to make it easier to separate mechanical from hand-crafted changes. If this is approved, however, I'll commit both changes tolaunch.next