WorkerImplementation<T> Type Alias
Given an interface T that defines the operations provided by a worker, produce an interface to which the implementation of those operations must conform. The return type of each function is enhanced to permit supplying a list of values to be transferred from the worker to the main thread. Multi-argument functions are converted to functions accepting a single tuple of arguments.
- Every return type
Ris converted toWorkerReturnType<R>. zeroArgFunc(): RbecomeszeroArgFunc(): R | { result: R; transfer: Transferable[]; }.oneArgFunc(arg: U): RbecomesoneArgFunc(arg: U): R | { result: R; transfer: Transferable[]; }.multiArgFunc(arg1: U, arg2: V): RbecomesmultiArgFunc([U, V]): R | { result: R; transfer: Transferable[]; }.
@note All parameters of all methods of T must support structured cloning -
attempts to pass functions, instances of classes, DOM nodes, WebGL resources, and other non-cloneable types will compile but fail at run-time.
Defined in
Last Updated: 24 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.