From 96c8267f71ce32657ff54159dd9c28ec8b952e4e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2023 08:29:01 +0100 Subject: [PATCH] Improve types to match reality (#10691) --- src/BasePlatform.ts | 2 +- src/utils/AutoDiscoveryUtils.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index edafff229f..da083f2716 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -75,7 +75,7 @@ export default abstract class BasePlatform { this.startUpdateCheck = this.startUpdateCheck.bind(this); } - public abstract getConfig(): Promise; + public abstract getConfig(): Promise; public abstract getDefaultDeviceDisplayName(): string; diff --git a/src/utils/AutoDiscoveryUtils.tsx b/src/utils/AutoDiscoveryUtils.tsx index 70f40af883..aaa602abb4 100644 --- a/src/utils/AutoDiscoveryUtils.tsx +++ b/src/utils/AutoDiscoveryUtils.tsx @@ -189,12 +189,12 @@ export default class AutoDiscoveryUtils { * @returns {Promise} Resolves to the validated configuration. */ public static buildValidatedConfigFromDiscovery( - serverName: string, - discoveryResult: ClientConfig, + serverName?: string, + discoveryResult?: ClientConfig, syntaxOnly = false, isSynthetic = false, ): ValidatedServerConfig { - if (!discoveryResult || !discoveryResult["m.homeserver"]) { + if (!discoveryResult?.["m.homeserver"]) { // This shouldn't happen without major misconfiguration, so we'll log a bit of information // in the log so we can find this bit of code but otherwise tell the user "it broke". logger.error("Ended up in a state of not knowing which homeserver to connect to."); @@ -249,7 +249,7 @@ export default class AutoDiscoveryUtils { throw new UserFriendlyError("Unexpected error resolving homeserver configuration"); } - let preferredHomeserverName = serverName ? serverName : hsResult["server_name"]; + let preferredHomeserverName = serverName ?? hsResult["server_name"]; const url = new URL(preferredHomeserverUrl); if (!preferredHomeserverName) preferredHomeserverName = url.hostname;