camunda-community-hub / zeebe-client-node-js

Node.js client library for Zeebe Microservices Orchestration Engine
https://camunda-community-hub.github.io/zeebe-client-node-js/
Apache License 2.0
152 stars 38 forks source link

Remove Partial<> from Parameterised type for Worker (complete.success) #198

Closed jwulf closed 3 years ago

jwulf commented 3 years ago

At the moment, the worker completion payload is a Partial. However, this erases type safety for required parameters.

If a programmer really has a Partial, they can put that in the signature.

Changing this will break the compilation of any code that uses type parameters on createWorker, if it relies on the existing implicit Partial<T>.

I don't think many people are using that at the moment - I'll check in Slack.

The benefit of making this change for type safety is significant, and the refactoring to fix the breaking change in users' code is T -> Partial<T> which is minimal and deterministic.

For example:

zbc.createWorker<INpmPackageQuery, {}, IndividualResult>

if the worker really returns only part of the IndividualResult type, it will need to be refactored to:

zbc.createWorker<INpmPackageQuery, {}, Partial<IndividualResult>>

The change needs to be made here: https://github.com/zeebe-io/zeebe-client-node-js/blob/master/src/lib/ZBWorkerBase.ts#L275