-
Notifications
You must be signed in to change notification settings - Fork 167
Clarification on using CloudEventsContext / Context type #425
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
Comments
Locally I was able to remove the and was able to get the type working correctly. Added some more findings on the issue in this comment. |
Hey @jketcham, can you provide an exact reproduction of the issue with some code? Have you tried importing In terms of guidance, we provide a set of types in this file: Which should be exported by default with the FF, from here: https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/master/src/index.ts A minimal sample of the issue would help. |
Hi @grant, I think the issue I ran into should be resolved when the next version of For reference, the code I had previously that was working fine was importing import { CloudEventsContext } from '@google-cloud/functions-framework'; I updated my code to instead import the |
OK, we will wait for a new version of |
Signed-off-by: Grant Timmerman <[email protected]>
* chore: update cloudevents. Fixes #425 Signed-off-by: Grant Timmerman <[email protected]> * chore: merge package json Signed-off-by: Grant Timmerman <[email protected]>
Hey @grant, I just tested out the new release for 3.0.0 with the update including I created a repo that reproduces the issue here: https://github.com/jketcham/cloudevents-ambient-const-enums This code is still giving that ambient const enums error when running import type { CloudEventV1 } from 'cloudevents';
import type { Context } from '@google-cloud/functions-framework';
export function handleWithCloudEvent(context: CloudEventV1<unknown>) {
console.log({ context });
}
export function handleWithContext(context: Context) {
console.log({ context });
} |
I have a cloud function (triggered by PubSub) I've written in Typescript and transpiled with babel which was using the
CloudEventsContext
type exported in version1.9.0
. When I tried to upgrade to version2.1.1
, I now get the following errors:It looks like I should now be using the
Context
type, but them I'm running into the sameCannot access ambient const enums
error with the--isolatedModules
flag, which looks like it's related to this issue with cloudevents itself: cloudevents/sdk-javascript#456.Can anyone provide any guidance on how I should type my cloud functions with CloudEvent context going forward? Is this something that needs to be addressed in the cloudevents repo?
Thank you!
The text was updated successfully, but these errors were encountered: