From 6a37a5dc27ad9c23296ba42dd81cac6cc9c2c55d Mon Sep 17 00:00:00 2001 From: KHeo Date: Tue, 19 Jul 2022 16:10:52 +0900 Subject: [PATCH] fix types. --- packages/network/lib/uri.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/network/lib/uri.ts b/packages/network/lib/uri.ts index 392c31b5e0c1..9e598013c367 100644 --- a/packages/network/lib/uri.ts +++ b/packages/network/lib/uri.ts @@ -15,6 +15,8 @@ const DEFAULT_PROTOCOL_PORTS = { 'http:': '80', } as const +type Protocols = keyof typeof DEFAULT_PROTOCOL_PORTS + const DEFAULT_PORTS = _.values(DEFAULT_PROTOCOL_PORTS) as string[] const portIsDefault = (port: string | null) => { @@ -74,7 +76,7 @@ export function addDefaultPort (urlToCheck: any) { /* @ts-ignore */ delete parsed.host if (parsed.protocol) { - parsed.port = DEFAULT_PROTOCOL_PORTS[parsed.protocol]! + parsed.port = DEFAULT_PROTOCOL_PORTS[parsed.protocol as Protocols] } else { /* @ts-ignore */ delete parsed.port