type: string,
isMain: boolean,
fn: (data: Data) => Response,
- protected mainWorker: MainWorker | null,
+ protected mainWorker: MainWorker | undefined | null,
public readonly opts: WorkerOptions = {
/**
* The kill behavior option on this Worker or its default value.
* @returns Message of the error.
*/
protected handleError (e: Error | string): string {
- return (e as unknown) as string
+ return e as string
}
/**
const res = fn(value.data)
this.sendToMainWorker({ data: res, id: value.id })
} catch (e) {
- const err = this.handleError(e)
+ const err = this.handleError(e as Error)
this.sendToMainWorker({ error: err, id: value.id })
} finally {
this.lastTaskTimestamp = Date.now()