feat: add typings for feature flags

pull/3281/head
yougotwill 3 months ago
parent 049685409b
commit 87f93d7719

@ -5,3 +5,14 @@ export type RenderTextCallbackType = (options: {
}) => JSX.Element; }) => JSX.Element;
export type LocalizerType = typeof window.i18n; export type LocalizerType = typeof window.i18n;
/**
* Recursively get all keys of an object, including nested objects treating them as strings
*/
export type RecursiveKeys<T> = T extends object
? {
[K in Extract<keyof T, string>]:
| K
| (T[K] extends object ? `${K}.${RecursiveKeys<T[K]>}` : never);
}[Extract<keyof T, string>]
: never;

36
ts/window.d.ts vendored

@ -13,6 +13,25 @@ export interface LibTextsecure {
messaging: boolean; messaging: boolean;
} }
export type SessionFeatureFlags = {
useOnionRequests: boolean;
useTestNet: boolean;
useClosedGroupV2: boolean;
useClosedGroupV2QAButtons: boolean;
forceLegacyGroupsDeprecated: boolean;
replaceLocalizedStringsWithKeys: boolean;
debug: {
debugLogging: boolean;
debugLibsessionDumps: boolean;
debugBuiltSnodeRequests: boolean;
debugFileServerRequests: boolean;
debugNonSnodeRequests: boolean;
debugOnionRequests: boolean;
};
};
export type SessionFeatureFlagsKeys = RecursiveKeys<SessionFeatureFlags>;
/* /*
We declare window stuff here instead of global.d.ts because we are importing other declarations. We declare window stuff here instead of global.d.ts because we are importing other declarations.
If you import anything in global.d.ts, the type system won't work correctly. If you import anything in global.d.ts, the type system won't work correctly.
@ -98,22 +117,7 @@ declare global {
inEnglish: I18nMethods['inEnglish']; inEnglish: I18nMethods['inEnglish'];
}; };
log: any; log: any;
sessionFeatureFlags: { sessionFeatureFlags: SessionFeatureFlags;
useOnionRequests: boolean;
useTestNet: boolean;
useClosedGroupV2: boolean;
useClosedGroupV2QAButtons: boolean;
forceLegacyGroupsDeprecated: boolean;
replaceLocalizedStringsWithKeys: boolean;
debug: {
debugLogging: boolean;
debugLibsessionDumps: boolean;
debugBuiltSnodeRequests: boolean;
debugFileServerRequests: boolean;
debugNonSnodeRequests: boolean;
debugOnionRequests: boolean;
};
};
onLogin: (pw: string) => Promise<void>; // only set on the password window onLogin: (pw: string) => Promise<void>; // only set on the password window
onTryPassword: (pw: string) => Promise<void>; // only set on the main window onTryPassword: (pw: string) => Promise<void>; // only set on the main window
persistStore?: Persistor; persistStore?: Persistor;

Loading…
Cancel
Save