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(); await tryResolveTrustedPromise();
} catch (e) { } catch (e: unknown) {
this.unverify(); this.unverify();
if (!resolved) { if (!resolved) {
reject(e); reject(e as Error);
resolved = true; resolved = true;
} else { } else {
console.warn('server request failed after returning cache value (or when already rejected)', e); 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); let overlayElement = createAddGuildOverlay(document, q, ui, guildsManager, addGuildData as IAddGuildData);
document.body.appendChild(overlayElement); document.body.appendChild(overlayElement);
} catch (e) { } catch (e: unknown) {
LOG.error('Unable to parse guild data', e); 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); 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...'; q.$$$(element, '.submit').innerText = 'Registering...';
try { try {
newGuild = await guildsManager.addNewGuild(addGuildData, displayName, avatarBuff); newGuild = await guildsManager.addNewGuild(addGuildData, displayName, avatarBuff);
} catch (e) { } catch (e: unknown) {
LOG.warn('error adding new guild: ' + e.message, e); // explicitly not printing stack trace here LOG.warn('error adding new guild: ' + (e as Error).message, e); // explicitly not printing stack trace here
q.$$$(element, '.error').innerText = e.message; q.$$$(element, '.error').innerText = (e as Error).message;
q.$$$(element, '.submit').innerText = 'Try Again'; q.$$$(element, '.submit').innerText = 'Try Again';
await ElementsUtil.shakeElement(q.$$$(element, '.submit'), 400); await ElementsUtil.shakeElement(q.$$$(element, '.submit'), 400);
newGuild = null; 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'); if (!resourceId) throw new ShouldNeverHappenError('resourceId is null and we are not using a pre-download');
try { try {
resourceBuff = (await guild.fetchResource(resourceId)).data; resourceBuff = (await guild.fetchResource(resourceId)).data;
} catch (e) { } catch (e: unknown) {
LOG.error('Error downloading resource', e); LOG.error('Error downloading resource', { e });
if (downloadFailFunc) await downloadFailFunc(e); if (downloadFailFunc) await downloadFailFunc(e as string);
downloading = false; downloading = false;
return; return;
} }

View File

@ -26,11 +26,11 @@ export default class Util {
try { try {
await fs.stat(path); await fs.stat(path);
return true; return true;
} catch (e) { } catch (e: unknown) {
if (e.code == 'ENOENT') { if ((e as any).code == 'ENOENT') {
return false; return false;
} else { } 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 () => { (async () => {
try { try {
taskData.resolve(await taskData.task()); taskData.resolve(await taskData.task());
} catch (e) { } catch (e: unknown) {
taskData.reject(e); taskData.reject(e as Error);
} }
this.current -= 1; this.current -= 1;
this._checkQueue(); this._checkQueue();

View File

@ -107,8 +107,8 @@ function bindEvent(
let hasPrivilege: boolean; let hasPrivilege: boolean;
try { try {
hasPrivilege = await DB.hasPrivilege(identity.guildId, identity.memberId, privilege); hasPrivilege = await DB.hasPrivilege(identity.guildId, identity.memberId, privilege);
} catch (e) { } catch (e: unknown) {
throw new EventError('not authorized', e, 'unable to check privilege'); throw new EventError('not authorized', e as Error, 'unable to check privilege');
} }
if (!hasPrivilege) { if (!hasPrivilege) {
throw new EventError('not authorized'); throw new EventError('not authorized');
@ -122,7 +122,7 @@ function bindEvent(
if (e instanceof EventError) { if (e instanceof EventError) {
throw e; throw e;
} else { } else {
throw new EventError(`unable to handle ${name} request`, e); throw new EventError(`unable to handle ${name} request`, e as Error);
} }
} }
} catch (e) { } catch (e) {
@ -221,9 +221,9 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
let memberInfo = await DB.getMemberInfo(identity.publicKey); let memberInfo = await DB.getMemberInfo(identity.publicKey);
identity.memberId = memberInfo.member_id; identity.memberId = memberInfo.member_id;
identity.guildId = memberInfo.guild_id; identity.guildId = memberInfo.guild_id;
} catch (e) { } catch (e: unknown) {
// unable to find a member with the specified public key // 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}`); 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; let verified: boolean;
try { try {
verified = verify.verify(identity.publicKey, signature, 'hex'); verified = verify.verify(identity.publicKey, signature, 'hex');
} catch (e) { } catch (e: unknown) {
throw new EventError('unable to verify signature', e); throw new EventError('unable to verify signature', e as Error);
} }
if (!verified) { if (!verified) {
@ -285,7 +285,7 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
await DB.setMemberStatus(identity.guildId, identity.memberId, 'online'); await DB.setMemberStatus(identity.guildId, identity.memberId, 'online');
let member = await DB.getMember(identity.guildId, identity.memberId); let member = await DB.getMember(identity.guildId, identity.memberId);
io.to(identity.guildId).emit('update-member', member); io.to(identity.guildId).emit('update-member', member);
} catch (e) { } catch (e: unknown) {
LOG.warn('unable to set status for m#' + identity.memberId, e); 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 // 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, "noImplicitAny": true,
"noPropertyAccessFromIndexSignature": true, "noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true, "noUncheckedIndexedAccess": true,
"strictFunctionTypes": true,
"strictBindCallApply": true, "strictBindCallApply": true,
"strictPropertyInitialization": true, "strictFunctionTypes": true,
"strictNullChecks": true, "strictNullChecks": true,
"strictPropertyInitialization": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true, "alwaysStrict": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "dist" "outDir": "dist"