Or is it String? and it evaluates to null if the condition is false. Having it be Any makes such a function about useless.
This sort of ambiguity is justification for it not to be in the standard library. You are free to define such a function yourself (as I said, I created a transformIf function) but it should not be in the standard library.
What is so strange or unusual about this? Generics often do this, reduce does this, even elvis operator does this and letIf case is similar to elvis. It is a very common thing to take a common supertype, even in stdlib.