If it were me, what I would do is create a function that takes a Param and returns a Query with the same data, call it toQuery() or something like that, and the same in reverse (a toParam() on the Query object - and then change the code to query[queryKey] = param[paramKey].toQuery()
Not that I've tested it, but it seems like that would remove a lot of your issues and probably all of them. In general, it makes sense to delegate to objects that need to turn themselves into other objects to do that themselves, rather than expect some supertyping or generic mechanism to do it for you in tricky cases like this one.