typing functions in TypeScript