Donald Trump was still fighting four legal battles as he declared victory in the US presidential election.