flexible functions in TypeScript