How to specify that a function which has several (but a limited amount) of possible types as inputs and outputs?

My code for formulating a specific JuMP optimisation model has started getting quite slow, and I would like to start optimising it by specifying types.

One of the main functions I call just searches through two dictionaries (which have either strings or symbols as keys) to return either 1) a Float64 2) an Int16 3) an array of either of those or 4) a string.

Is there a way of telling Julia that these are the only possible options, so that it can compile this function?

Restricting the input types doesn’t change performance. See https://docs.julialang.org/en/v1/manual/performance-tips/

There must be something else slowing down my code then…