Skip to content

Commit 7b7f60e

Browse files
committed
Improves types in remoteProviders for cloudRemotesMap: makes it stricter
(#4107, #4146)
1 parent ede7d04 commit 7b7f60e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/git/remotes/remoteProviders.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RemotesConfig } from '../../config';
2+
import type { CloudSelfHostedIntegrationId } from '../../constants.integrations';
23
import { SelfHostedIntegrationId } from '../../constants.integrations';
34
import type { Container } from '../../container';
45
import type { ConfiguredIntegrationDescriptor } from '../../plus/integrations/authentication/models';
@@ -76,7 +77,10 @@ const builtInProviders: RemoteProviders = [
7677
},
7778
];
7879

79-
const cloudRemotesMap: { [key: string]: typeof GitHubRemote | typeof GitLabRemote | typeof BitbucketServerRemote } = {
80+
const cloudRemotesMap: Record<
81+
CloudSelfHostedIntegrationId,
82+
typeof GitHubRemote | typeof GitLabRemote | typeof BitbucketServerRemote
83+
> = {
8084
[SelfHostedIntegrationId.CloudGitHubEnterprise]: GitHubRemote,
8185
[SelfHostedIntegrationId.CloudGitLabSelfHosted]: GitLabRemote,
8286
[SelfHostedIntegrationId.BitbucketServer]: BitbucketServerRemote,
@@ -111,10 +115,11 @@ export function loadRemoteProviders(
111115

112116
if (configuredIntegrations?.length) {
113117
for (const ci of configuredIntegrations) {
114-
if (isCloudSelfHostedIntegrationId(ci.integrationId) && ci.domain) {
118+
const integrationId = ci.integrationId;
119+
if (isCloudSelfHostedIntegrationId(integrationId) && ci.domain) {
115120
const matcher = ci.domain.toLocaleLowerCase();
116121
const providerCreator = (_container: Container, domain: string, path: string): RemoteProvider =>
117-
new cloudRemotesMap[ci.integrationId](domain, path);
122+
new cloudRemotesMap[integrationId](domain, path);
118123
const provider = {
119124
custom: false,
120125
matcher: matcher,

0 commit comments

Comments
 (0)