Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
parent
ac7f69216e
commit
61a63e47f4
359 changed files with 1621 additions and 1353 deletions
|
@ -118,10 +118,9 @@ export interface IBaseSetting<T extends SettingValueType = SettingValueType> {
|
|||
// Display name can also be an object for different levels.
|
||||
displayName?:
|
||||
| string
|
||||
| {
|
||||
// @ts-ignore - TS wants the key to be a string, but we know better
|
||||
[level: SettingLevel]: string;
|
||||
};
|
||||
| Partial<{
|
||||
[level in SettingLevel]: string;
|
||||
}>;
|
||||
|
||||
// Optional description which will be shown as microCopy under SettingsFlags
|
||||
description?: string | (() => ReactNode);
|
||||
|
|
|
@ -42,9 +42,9 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
|
|||
const defaultWatchManager = new WatchManager();
|
||||
|
||||
// Convert the settings to easier to manage objects for the handlers
|
||||
const defaultSettings = {};
|
||||
const invertedDefaultSettings = {};
|
||||
const featureNames = [];
|
||||
const defaultSettings: Record<string, any> = {};
|
||||
const invertedDefaultSettings: Record<string, boolean> = {};
|
||||
const featureNames: string[] = [];
|
||||
for (const key of Object.keys(SETTINGS)) {
|
||||
defaultSettings[key] = SETTINGS[key].default;
|
||||
if (SETTINGS[key].isFeature) featureNames.push(key);
|
||||
|
@ -56,7 +56,7 @@ for (const key of Object.keys(SETTINGS)) {
|
|||
}
|
||||
|
||||
// Only wrap the handlers with async setters in a local echo wrapper
|
||||
const LEVEL_HANDLERS = {
|
||||
const LEVEL_HANDLERS: Record<SettingLevel, SettingsHandler> = {
|
||||
[SettingLevel.DEVICE]: new DeviceSettingsHandler(featureNames, defaultWatchManager),
|
||||
[SettingLevel.ROOM_DEVICE]: new RoomDeviceSettingsHandler(defaultWatchManager),
|
||||
[SettingLevel.ROOM_ACCOUNT]: new LocalEchoWrapper(
|
||||
|
@ -97,10 +97,9 @@ export type CallbackFn = (
|
|||
newVal: any,
|
||||
) => void;
|
||||
|
||||
interface IHandlerMap {
|
||||
// @ts-ignore - TS wants this to be a string key but we know better
|
||||
[level: SettingLevel]: SettingsHandler;
|
||||
}
|
||||
type HandlerMap = Partial<{
|
||||
[level in SettingLevel]: SettingsHandler;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Controls and manages application settings by providing varying levels at which the
|
||||
|
@ -646,15 +645,17 @@ export default class SettingsStore {
|
|||
logger.log(`--- default level order: ${JSON.stringify(LEVEL_ORDER)}`);
|
||||
logger.log(`--- registered handlers: ${JSON.stringify(Object.keys(LEVEL_HANDLERS))}`);
|
||||
|
||||
const doChecks = (settingName): void => {
|
||||
const doChecks = (settingName: string): void => {
|
||||
for (const handlerName of Object.keys(LEVEL_HANDLERS)) {
|
||||
const handler = LEVEL_HANDLERS[handlerName];
|
||||
const handler = LEVEL_HANDLERS[handlerName as SettingLevel];
|
||||
|
||||
try {
|
||||
const value = handler.getValue(settingName, roomId);
|
||||
logger.log(`--- ${handlerName}@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- ${handler}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.log(
|
||||
`--- ${handler.constructor.name}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`,
|
||||
);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -663,7 +664,7 @@ export default class SettingsStore {
|
|||
const value = handler.getValue(settingName, null);
|
||||
logger.log(`--- ${handlerName}@<no_room> = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- ${handler}@<no_room> THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- ${handler.constructor.name}@<no_room> THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
@ -728,10 +729,10 @@ export default class SettingsStore {
|
|||
return handlers[level];
|
||||
}
|
||||
|
||||
private static getHandlers(settingName: string): IHandlerMap {
|
||||
private static getHandlers(settingName: string): HandlerMap {
|
||||
if (!SETTINGS[settingName]) return {};
|
||||
|
||||
const handlers = {};
|
||||
const handlers: Partial<Record<SettingLevel, SettingsHandler>> = {};
|
||||
for (const level of SETTINGS[settingName].supportedLevels) {
|
||||
if (!LEVEL_HANDLERS[level]) throw new Error("Unexpected level " + level);
|
||||
if (SettingsStore.isLevelSupported(level)) handlers[level] = LEVEL_HANDLERS[level];
|
||||
|
|
|
@ -48,5 +48,5 @@ export default abstract class MatrixClientBackedSettingsHandler extends Settings
|
|||
return MatrixClientBackedSettingsHandler._matrixClient;
|
||||
}
|
||||
|
||||
protected abstract initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient);
|
||||
protected abstract initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient): void;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ export default class PlatformSettingsHandler extends SettingsHandler {
|
|||
// Load setting values as they are async and `getValue` must be synchronous
|
||||
Object.entries(SETTINGS).forEach(([key, setting]) => {
|
||||
if (setting.supportedLevels.includes(SettingLevel.PLATFORM) && payload.platform.supportsSetting(key)) {
|
||||
payload.platform.getSettingValue(key).then((value) => {
|
||||
payload.platform.getSettingValue(key).then((value: any) => {
|
||||
this.store[key] = value;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue