tsc:allowUnreachableCode, eslint:no-unreachable, assert->assertDev

This commit is contained in:
Jamie Kyle 2022-09-15 12:17:15 -07:00 committed by GitHub
parent f627a05cf8
commit eb10aafd7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 213 additions and 176 deletions

View file

@ -30,7 +30,7 @@ import {
import { UUID, UUIDKind } from '../types/UUID';
import { isMoreRecentThan, isOlderThan } from '../util/timestamp';
import { ourProfileKeyService } from '../services/ourProfileKey';
import { assert, strictAssert } from '../util/assert';
import { assertDev, strictAssert } from '../util/assert';
import { getRegionCodeForNumber } from '../util/libphonenumberUtil';
import { getProvisioningUrl } from '../util/getProvisioningUrl';
import { isNotNil } from '../util/isNotNil';
@ -114,7 +114,7 @@ export default class AccountManager extends EventTarget {
const bytes = Bytes.fromBase64(base64);
const proto = Proto.DeviceName.decode(bytes);
assert(
assertDev(
proto.ephemeralPublic && proto.syntheticIv && proto.ciphertext,
'Missing required fields in DeviceName'
);

View file

@ -16,7 +16,7 @@ import {
import type { QuotedMessageType } from '../model-types.d';
import type { ConversationModel } from '../models/conversations';
import { GLOBAL_ZONE } from '../SignalProtocolStore';
import { assert, strictAssert } from '../util/assert';
import { assertDev, strictAssert } from '../util/assert';
import { parseIntOrThrow } from '../util/parseIntOrThrow';
import { Address } from '../types/Address';
import { QualifiedAddress } from '../types/QualifiedAddress';
@ -673,7 +673,7 @@ export default class MessageSender {
Pick<AttachmentType, 'data' | 'size' | 'contentType'>
>
): Promise<Proto.IAttachmentPointer> {
assert(
assertDev(
typeof attachment === 'object' && attachment != null,
'Got null attachment in `makeAttachmentPointer`'
);
@ -1300,7 +1300,7 @@ export default class MessageSender {
timestamp: number;
urgent: boolean;
}>): Promise<CallbackResultType> {
assert(identifier, "Identifier can't be undefined");
assertDev(identifier, "Identifier can't be undefined");
return new Promise((resolve, reject) => {
const callback = (res: CallbackResultType) => {
if (res && res.errors && res.errors.length > 0) {

View file

@ -8,7 +8,7 @@ import type {
import { User } from './storage/User';
import { Blocked } from './storage/Blocked';
import { assert } from '../util/assert';
import { assertDev } from '../util/assert';
import Data from '../sql/Client';
import type { SignalProtocolStore } from '../SignalProtocolStore';
import * as log from '../logging/log';
@ -34,7 +34,7 @@ export class Storage implements StorageInterface {
}
get protocol(): SignalProtocolStore {
assert(
assertDev(
this.privProtocol !== undefined,
'SignalProtocolStore not initialized'
);

View file

@ -9,7 +9,7 @@ import EventTarget from './EventTarget';
import MessageReceiver from './MessageReceiver';
import type { ContactSyncEvent, GroupSyncEvent } from './messageReceiverEvents';
import MessageSender from './SendMessage';
import { assert } from '../util/assert';
import { assertDev } from '../util/assert';
import * as log from '../logging/log';
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
import * as Errors from '../types/errors';
@ -49,7 +49,10 @@ class SyncRequestInner extends EventTarget {
async start(): Promise<void> {
if (this.started) {
assert(false, 'SyncRequestInner: started more than once. Doing nothing');
assertDev(
false,
'SyncRequestInner: started more than once. Doing nothing'
);
return;
}
this.started = true;

View file

@ -18,7 +18,7 @@ import { v4 as getGuid } from 'uuid';
import { z } from 'zod';
import type { Readable } from 'stream';
import { assert, strictAssert } from '../util/assert';
import { assertDev, strictAssert } from '../util/assert';
import { isRecord } from '../util/isRecord';
import * as durations from '../util/durations';
import type { ExplodePromiseResultType } from '../util/explodePromise';
@ -391,7 +391,7 @@ async function _promiseAjax(
log.info(logId, response.status, 'Success');
if (options.responseType === 'byteswithdetails') {
assert(result instanceof Uint8Array, 'Expected Uint8Array result');
assertDev(result instanceof Uint8Array, 'Expected Uint8Array result');
const fullResult: BytesWithDetailsType = {
data: result,
contentType: getContentType(response),

View file

@ -5,7 +5,7 @@ import Long from 'long';
import { ReceiptCredentialPresentation } from '@signalapp/libsignal-client/zkgroup';
import { isNumber } from 'lodash';
import { assert, strictAssert } from '../util/assert';
import { assertDev, strictAssert } from '../util/assert';
import { dropNull, shallowDropNull } from '../util/dropNull';
import { SignalService as Proto } from '../protobuf';
import { deriveGroupFields } from '../groups';
@ -331,7 +331,7 @@ export async function processDataMessage(
isExpirationTimerUpdate,
isProfileKeyUpdate,
].filter(Boolean).length;
assert(
assertDev(
flagCount <= 1,
`Expected exactly <=1 flags to be set, but got ${flagCount}`
);