Looking for advice on how to generalize a TypeScript method. Here's my current approach - I want to find a way to reduce the amount of code in this method.
function getAuthProvider(authProvider) {
let provider;
switch (authProvider) {
case 'google':
provider = new firebase.auth.GoogleAuthProvider();
break;
case 'facebook':
provider = new firebase.auth.FacebookAuthProvider();
break;
case 'twitter':
provider = new firebase.auth.TwitterAuthProvider();
break;
case 'microsoft':
provider = new firebase.auth.OAuthProvider('microsoft.com');
provider.setCustomParameters({ tenant: 'b7773erqqqfr5678' });
break;
default:
provider = null;
}
return provider;
}
Is there a more efficient way to write this method?