[TS] Various cleanups

This commit is contained in:
Beef 2023-03-20 21:30:13 +00:00
parent 13cf5e6872
commit 4d10691ac1
2 changed files with 10 additions and 6 deletions

14
src/def.d.ts vendored
View file

@ -371,7 +371,7 @@ interface VendettaObject {
utils: {
findInReactTree: (tree: SearchTree, filter: SearchFilter) => any;
findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any;
safeFetch: (input: RequestInfo, options: RequestInit) => Promise<Response>;
safeFetch: (input: RequestInfo | URL, options?: RequestInit) => Promise<Response>;
unfreeze: (obj: object) => object;
};
debug: {
@ -411,17 +411,21 @@ interface VendettaObject {
};
plugins: {
plugins: Indexable<Plugin>;
fetchPlugin: (id: string, enabled: boolean) => void;
installPlugin: (id: string, enabled: boolean) => void;
fetchPlugin: (id: string) => void;
installPlugin: (id: string, enabled?: boolean) => void;
evalPlugin: (plugin: Plugin) => void;
stopPlugin: (id: string, disable: boolean) => void;
stopPlugin: (id: string, disable?: boolean) => void;
removePlugin: (id: string) => void;
getSettings: (id: string) => JSX.Element;
};
themes: {
themes: Indexable<Theme>;
fetchTheme: (id: string) => void;
fetchTheme: (id: string, selected?: boolean) => void;
installTheme: (id: string) => void;
selectTheme: (id: string) => void;
removeTheme: (id: string) => Promise<boolean>;
getCurrentTheme: () => Theme | null;
updateThemes: () => void;
};
commands: {
registerCommand: (command: ApplicationCommand) => () => void;

View file

@ -1,6 +1,6 @@
// A really basic fetch wrapper which throws on non-ok response codes
export default async function safeFetch(input: RequestInfo, options?: RequestInit) {
export default async function safeFetch(input: RequestInfo | URL, options?: RequestInit) {
const req = await fetch(input, options);
if (!req.ok) throw new Error("Request returned non-ok");
return req;