typescript if object implements interface