Skip to content

Commit

Permalink
strict ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Jan 1, 2022
1 parent c57d05f commit 54a1bcb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
10 changes: 5 additions & 5 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async function getTotp(text: string, silent = false) {

try {
label = decodeURIComponent(label);
} catch (error) {
} catch (error: any) {
console.error(error);
}
if (label.indexOf(":") !== -1) {
Expand Down Expand Up @@ -411,7 +411,7 @@ function getBackupToken(service: string) {
localStorage.driveRefreshToken = res.refresh_token;
resolve(true);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -453,7 +453,7 @@ function getBackupToken(service: string) {
res.refresh_token;
resolve(true);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -530,7 +530,7 @@ chrome.runtime.onInstalled.addListener(async (details) => {
chrome.commands.onCommand.addListener(async (command: string) => {
switch (command) {
case "scan-qr":
await new Promise(
await new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
return chrome.tabs.executeScript(
Expand All @@ -539,7 +539,7 @@ chrome.commands.onCommand.addListener(async (command: string) => {
chrome.tabs.insertCSS({ file: "/css/content.css" }, resolve);
}
);
} catch (error) {
} catch (error: any) {
console.error(error);
return reject(error);
}
Expand Down
24 changes: 12 additions & 12 deletions src/models/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export class Dropbox implements BackupProvider {
} else {
resolve(false);
}
} catch (error) {
} catch (error: any) {
reject(error);
}
}
return;
};
xhr.send(backup);
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ export class Drive implements BackupProvider {
} else {
resolve(false);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -216,7 +216,7 @@ export class Drive implements BackupProvider {
localStorage.driveToken = res.access_token;
resolve(true);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -271,7 +271,7 @@ export class Drive implements BackupProvider {
} else {
resolve(true);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -309,7 +309,7 @@ export class Drive implements BackupProvider {
console.error(res.error.message);
resolve(false);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -374,7 +374,7 @@ export class Drive implements BackupProvider {
console.error(res.error.message);
resolve(false);
}
} catch (error) {
} catch (error: any) {
reject(error);
}
}
Expand All @@ -400,7 +400,7 @@ export class Drive implements BackupProvider {
requestData = requestData + line + "\n";
});
xhr.send(requestData);
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down Expand Up @@ -478,7 +478,7 @@ export class OneDrive implements BackupProvider {
} else {
resolve(false);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -526,7 +526,7 @@ export class OneDrive implements BackupProvider {
localStorage.oneDriveToken = res.access_token;
resolve(true);
}
} catch (error) {
} catch (error: any) {
console.error(error);
reject(error);
}
Expand Down Expand Up @@ -589,14 +589,14 @@ export class OneDrive implements BackupProvider {
console.error(res.error.message);
resolve(false);
}
} catch (error) {
} catch (error: any) {
reject(error);
}
}
return;
};
xhr.send(backup);
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/models/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class BrowserStorage {
// https://github.com/Authenticator-Extension/Authenticator/issues/412
static async clearLogs() {
const storageLocation = await this.getStorageLocation();
await new Promise((resolve: () => void) => {
await new Promise<void>((resolve: () => void) => {
if (storageLocation === "local") {
chrome.storage.local.get((data) => {
chrome.storage.local.clear(() => {
Expand Down Expand Up @@ -366,15 +366,15 @@ export class EntryStorage {
return resolve(_data);
});
return;
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
);
}

static import(encryption: Encryption, data: { [hash: string]: OTPStorage }) {
return new Promise(
return new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
BrowserStorage.get(async (_data: { [hash: string]: OTPStorage }) => {
Expand Down Expand Up @@ -479,30 +479,30 @@ export class EntryStorage {
BrowserStorage.set(_data, resolve);
});
return;
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
);
}

static add(entry: OTPEntry) {
return new Promise(
return new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
BrowserStorage.set(
{ [entry.hash]: this.getOTPStorageFromEntry(entry) },
resolve
);
} catch (error) {
} catch (error: any) {
reject(error);
}
}
);
}

static update(entry: OTPEntry) {
return new Promise(
return new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
BrowserStorage.get((_data: { [hash: string]: OTPStorage }) => {
Expand All @@ -515,15 +515,15 @@ export class EntryStorage {
BrowserStorage.set(_data, resolve);
});
return;
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
);
}

static set(entries: OTPEntry[]) {
return new Promise(
return new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
BrowserStorage.get((_data: { [hash: string]: OTPStorage }) => {
Expand All @@ -535,7 +535,7 @@ export class EntryStorage {
BrowserStorage.set(_data, resolve);
});
return;
} catch (error) {
} catch (error: any) {
reject(error);
}
}
Expand Down Expand Up @@ -619,21 +619,21 @@ export class EntryStorage {
return resolve(data);
});
return;
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
);
}

static remove(hash: string) {
return new Promise((resolve: () => void) => {
return new Promise<void>((resolve: () => void) => {
return BrowserStorage.remove(hash, resolve);
});
}

static delete(entry: OTPEntry) {
return new Promise(
return new Promise<void>(
(resolve: () => void, reject: (reason: Error) => void) => {
try {
BrowserStorage.get((_data: { [hash: string]: OTPStorage }) => {
Expand All @@ -647,7 +647,7 @@ export class EntryStorage {
return;
});
return;
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export function syncTimeWithGoogle() {
}
};
xhr.send();
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/Accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class Accounts implements Module {
key: { enc: encKey, hash: encKeyHash },
});
await EntryStorage.set(state.state.entries);
await new Promise((resolve) => {
await new Promise<void>((resolve) => {
BrowserStorage.remove(oldKeys, () => {
resolve();
});
Expand Down Expand Up @@ -377,7 +377,7 @@ export class Accounts implements Module {
});
await EntryStorage.set(state.state.entries);
if (removeHashes.length) {
await new Promise((resolve) => {
await new Promise<void>((resolve) => {
BrowserStorage.remove(removeHashes, () => {
resolve();
});
Expand Down
2 changes: 1 addition & 1 deletion src/store/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function loadI18nMessages() {
};
xhr.open("GET", chrome.extension.getURL("/_locales/en/messages.json"));
xhr.send();
} catch (error) {
} catch (error: any) {
return reject(error);
}
}
Expand Down

0 comments on commit 54a1bcb

Please sign in to comment.