Typescript Convert Json Object Into Javascript Function Definition