Skip to content

Event context can be undefined according to type definitions #227

@0x80

Description

@0x80

According to the 1.0.0 Typescript definitions the context part of an event is defined as EventContext | undefined. For example:

const myFunction = firestore
  .document(`collection/{documentId}`)
  .onCreate((data, context) => {
    // Check if context is defined?
  });

I have a hard time imagining why this would ever be undefined, so I am currently ignoring it.

Context as the second parameter to the handler function is optional, because you can supply a handler with just the data argument. But shouldn't that be solved via overloading? If I supply a function with both arguments then context should be guaranteed to exist, no?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions