Typescript behaving strangely when inferring function return type - Theo's Typesafe Cult