even more strict typescript options

This commit is contained in:
Michael Peters 2021-12-04 08:40:08 -06:00
parent 76eb8e4e01
commit 127674d8e5
8 changed files with 26 additions and 25 deletions

View File

@ -251,10 +251,10 @@ export class AutoVerifier<T> {
}
}
await tryResolveTrustedPromise();
} catch (e) {
} catch (e: unknown) {
this.unverify();
if (!resolved) {
reject(e);
reject(e as Error);
resolved = true;
} else {
console.warn('server request failed after returning cache value (or when already rejected)', e);

View File

@ -53,9 +53,9 @@ export default function bindAddGuildEvents(document: Document, q: Q, ui: UI, gui
}
let overlayElement = createAddGuildOverlay(document, q, ui, guildsManager, addGuildData as IAddGuildData);
document.body.appendChild(overlayElement);
} catch (e) {
} catch (e: unknown) {
LOG.error('Unable to parse guild data', e);
let errorOverlayElement = createErrorMessageOverlay(document, 'Unable to parse guild file', e.message);
let errorOverlayElement = createErrorMessageOverlay(document, 'Unable to parse guild file', (e as Error).message);
document.body.appendChild(errorOverlayElement);
}

View File

@ -201,9 +201,9 @@ export default function createAddGuildOverlay(document: Document, q: Q, ui: UI,
q.$$$(element, '.submit').innerText = 'Registering...';
try {
newGuild = await guildsManager.addNewGuild(addGuildData, displayName, avatarBuff);
} catch (e) {
LOG.warn('error adding new guild: ' + e.message, e); // explicitly not printing stack trace here
q.$$$(element, '.error').innerText = e.message;
} catch (e: unknown) {
LOG.warn('error adding new guild: ' + (e as Error).message, e); // explicitly not printing stack trace here
q.$$$(element, '.error').innerText = (e as Error).message;
q.$$$(element, '.submit').innerText = 'Try Again';
await ElementsUtil.shakeElement(q.$$$(element, '.submit'), 400);
newGuild = null;

View File

@ -366,9 +366,9 @@ export default class ElementsUtil {
if (!resourceId) throw new ShouldNeverHappenError('resourceId is null and we are not using a pre-download');
try {
resourceBuff = (await guild.fetchResource(resourceId)).data;
} catch (e) {
LOG.error('Error downloading resource', e);
if (downloadFailFunc) await downloadFailFunc(e);
} catch (e: unknown) {
LOG.error('Error downloading resource', { e });
if (downloadFailFunc) await downloadFailFunc(e as string);
downloading = false;
return;
}

View File

@ -26,11 +26,11 @@ export default class Util {
try {
await fs.stat(path);
return true;
} catch (e) {
if (e.code == 'ENOENT') {
} catch (e: unknown) {
if ((e as any).code == 'ENOENT') {
return false;
} else {
throw new Error('Error checking if file exists: ' + e.code);
throw new Error('Error checking if file exists: ' + (e as any).code);
}
}
}

View File

@ -31,8 +31,8 @@ export default class ConcurrentQueue<T> {
(async () => {
try {
taskData.resolve(await taskData.task());
} catch (e) {
taskData.reject(e);
} catch (e: unknown) {
taskData.reject(e as Error);
}
this.current -= 1;
this._checkQueue();

View File

@ -107,8 +107,8 @@ function bindEvent(
let hasPrivilege: boolean;
try {
hasPrivilege = await DB.hasPrivilege(identity.guildId, identity.memberId, privilege);
} catch (e) {
throw new EventError('not authorized', e, 'unable to check privilege');
} catch (e: unknown) {
throw new EventError('not authorized', e as Error, 'unable to check privilege');
}
if (!hasPrivilege) {
throw new EventError('not authorized');
@ -122,7 +122,7 @@ function bindEvent(
if (e instanceof EventError) {
throw e;
} else {
throw new EventError(`unable to handle ${name} request`, e);
throw new EventError(`unable to handle ${name} request`, e as Error);
}
}
} catch (e) {
@ -221,9 +221,9 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
let memberInfo = await DB.getMemberInfo(identity.publicKey);
identity.memberId = memberInfo.member_id;
identity.guildId = memberInfo.guild_id;
} catch (e) {
} catch (e: unknown) {
// unable to find a member with the specified public key
throw new EventError('unauthorized public key', e);
throw new EventError('unauthorized public key', e as Error);
}
LOG.debug(`c#${client.id}: challenging for u#${identity.memberId}`);
@ -273,8 +273,8 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
let verified: boolean;
try {
verified = verify.verify(identity.publicKey, signature, 'hex');
} catch (e) {
throw new EventError('unable to verify signature', e);
} catch (e: unknown) {
throw new EventError('unable to verify signature', e as Error);
}
if (!verified) {
@ -285,7 +285,7 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
await DB.setMemberStatus(identity.guildId, identity.memberId, 'online');
let member = await DB.getMember(identity.guildId, identity.memberId);
io.to(identity.guildId).emit('update-member', member);
} catch (e) {
} catch (e: unknown) {
LOG.warn('unable to set status for m#' + identity.memberId, e);
// not killing here since this should not be a game ender. Most likely, the SQL server is bad though
}

View File

@ -10,10 +10,11 @@
"noImplicitAny": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
"skipLibCheck": true,
"outDir": "dist"