Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Improve types to match reality #10691

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default abstract class BasePlatform {
this.startUpdateCheck = this.startUpdateCheck.bind(this);
}

public abstract getConfig(): Promise<IConfigOptions>;
public abstract getConfig(): Promise<IConfigOptions | undefined>;

public abstract getDefaultDeviceDisplayName(): string;

Expand Down
8 changes: 4 additions & 4 deletions src/utils/AutoDiscoveryUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ export default class AutoDiscoveryUtils {
* @returns {Promise<ValidatedServerConfig>} 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.");
Expand Down Expand Up @@ -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;
Expand Down