- const { taskFunctionOperation, taskFunction, taskFunctionName } = message
- let response!: TaskFunctionOperationReturnType
- if (taskFunctionOperation === 'has') {
- response = this.hasTaskFunction(taskFunctionName as string)
- } else if (taskFunctionOperation === 'add') {
- response = this.addTaskFunction(
- taskFunctionName as string,
- // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
- new Function(`return ${taskFunction as string}`)() as TaskFunction<
- Data,
- Response
- >
+ const { taskFunctionOperation, taskFunctionName, taskFunction } = message
+ if (taskFunctionName == null) {
+ throw new Error(
+ 'Cannot handle task function operation message without a task function name'