JSDoc: Documenting a function with interdependent parameters

I have a function which takes in two parameters, something like:

function example(type, val) {
  // handle "val" based on "type"
}

The acceptable types for val depend on type. The type parameter will always be one of a few select strings. For example, my JSDoc may look something like the following:

/**
 * Handles the value of "val" based on the "type" parameter.
 * @function example
 * @param {"number" | "string" | "boolean"} type - The type of the "val" parameter.
 * @param { ????? } val - The value to handle.
 * @returns {void}
 */
function example(type, val) {
  // handle "val" based on "type"
}

It’s worth noting that "number", "string", and "boolean" aren’t actually the allowed values of type in my real code; I’m only using them here for demonstration as it makes the problem easier to understand.

As seen in the above code, type can take on a few select values. If type="number", for example, then val should only be allowed to be a number.

I thought I could union a few typedefs together to achieve the result I’m looking for, but I wasn’t entirely sure how this would even work as I’m dealing with functions, not objects.

Any suggestions would be appreciated!