Graphile Worker is written in TypeScript. By default, for safety, payloads are typed as unknown since they may have been populated by out of date code, or even from other sources. This requires you to add a type guard or similar to ensure the payload conforms to what you expect. It can be convenient to declare the payload types up front to avoid this unknown, but doing so might be unsafe — please be sure to read the caveats below.
We currently declare the payload types within some specific tasks, without any additional code to let TypeScript know that this type narrowing is ok.
Type '(payload: LogRecord, helpers: JobHelpers) => Promise<void>' is not assignable to type 'Task'.
Types of parameters 'payload' and 'payload' are incompatible.
Type 'unknown' is not assignable to type 'LogRecord'.ts(2322)
Expected behavior
Proper typing so that TS won't complain 😁
Describe the bug From the Graphile Worker docs:
We currently declare the payload types within some specific tasks, without any additional code to let TypeScript know that this type narrowing is ok.
To Reproduce Steps to reproduce the behavior:
handle-deliery-report.ts
Expected behavior Proper typing so that TS won't complain 😁
Additional context See suggestions here https://worker.graphile.org/docs/typescript