From 26e0d2c226d5c4ae2b5a33883216be785f28b7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gillot-Lamure?= Date: Tue, 28 Nov 2017 17:38:14 +0000 Subject: [PATCH] Parameter in callback should not be optionnal Using `?` in this situation would mean that you may, *or may not*, pass the `done` parameter to the callback. It does not mean that the callback can use it or not. You probably always pass the `done` parameter to the callback. See https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#optional-parameters-in-callbacks Having `?` here is annoying for the caller when they use --strictNullChecks because they have to use `!` (the non-null assertion) whenever they use `done` to tell the compiler that it actually will never be null. --- types/agenda/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/agenda/index.d.ts b/types/agenda/index.d.ts index d170a6f6f1..426b187d7c 100644 --- a/types/agenda/index.d.ts +++ b/types/agenda/index.d.ts @@ -113,8 +113,8 @@ declare class Agenda extends EventEmitter { * @param options The options for the job. * @param handler The handler to execute. */ - define(name: string, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; - define(name: string, options: Agenda.JobOptions, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; + define(name: string, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void; + define(name: string, options: Agenda.JobOptions, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void; /** * Runs job name at the given interval. Optionally, data and options can be passed in.