Typescript Nested Functions