typescript function and object and advanced types