tsc:allowUnreachableCode, eslint:no-unreachable, assert->assertDev
This commit is contained in:
parent
f627a05cf8
commit
eb10aafd7c
57 changed files with 213 additions and 176 deletions
|
@ -27,7 +27,7 @@ import { tapToViewMessagesDeletionService } from '../services/tapToViewMessagesD
|
|||
import * as Bytes from '../Bytes';
|
||||
import { CURRENT_SCHEMA_VERSION } from '../types/Message2';
|
||||
import { createBatcher } from '../util/batcher';
|
||||
import { assert, softAssert, strictAssert } from '../util/assert';
|
||||
import { assertDev, softAssert, strictAssert } from '../util/assert';
|
||||
import { mapObjectWithSpec } from '../util/mapObjectWithSpec';
|
||||
import type { ObjectMappingSpecType } from '../util/mapObjectWithSpec';
|
||||
import { cleanDataForIpc } from './cleanDataForIpc';
|
||||
|
@ -460,7 +460,7 @@ export function _cleanMessageData(data: MessageType): MessageType {
|
|||
const result = { ...data };
|
||||
// Ensure that all messages have the received_at set properly
|
||||
if (!data.received_at) {
|
||||
assert(false, 'received_at was not set on the message');
|
||||
assertDev(false, 'received_at was not set on the message');
|
||||
result.received_at = window.Signal.Util.incrementMessageCounter();
|
||||
}
|
||||
if (data.attachments) {
|
||||
|
@ -1052,7 +1052,7 @@ const updateConversationBatcher = createBatcher<ConversationType>({
|
|||
const ids = Object.keys(byId);
|
||||
const mostRecent = ids.map((id: string): ConversationType => {
|
||||
const maybeLast = last(byId[id]);
|
||||
assert(maybeLast !== undefined, 'Empty array in `groupBy` result');
|
||||
assertDev(maybeLast !== undefined, 'Empty array in `groupBy` result');
|
||||
return maybeLast;
|
||||
});
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ async function updateConversations(
|
|||
array: Array<ConversationType>
|
||||
): Promise<void> {
|
||||
const { cleaned, pathsChanged } = cleanDataForIpc(array);
|
||||
assert(
|
||||
assertDev(
|
||||
!pathsChanged.length,
|
||||
`Paths were cleaned: ${JSON.stringify(pathsChanged)}`
|
||||
);
|
||||
|
|
|
@ -34,7 +34,7 @@ import { STORAGE_UI_KEYS } from '../types/StorageUIKeys';
|
|||
import { UUID } from '../types/UUID';
|
||||
import type { UUIDStringType } from '../types/UUID';
|
||||
import type { StoredJob } from '../jobs/types';
|
||||
import { assert, assertSync, strictAssert } from '../util/assert';
|
||||
import { assertDev, assertSync, strictAssert } from '../util/assert';
|
||||
import { combineNames } from '../util/combineNames';
|
||||
import { consoleLogger } from '../util/consoleLogger';
|
||||
import { dropNull } from '../util/dropNull';
|
||||
|
@ -376,7 +376,7 @@ function rowToConversation(row: ConversationRow): ConversationType {
|
|||
if (isNormalNumber(row.profileLastFetchedAt)) {
|
||||
profileLastFetchedAt = row.profileLastFetchedAt;
|
||||
} else {
|
||||
assert(
|
||||
assertDev(
|
||||
isNil(row.profileLastFetchedAt),
|
||||
'profileLastFetchedAt contained invalid data; defaulting to undefined'
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@ import { omit } from 'lodash';
|
|||
import type { LoggerType } from '../../types/Logging';
|
||||
import type { UUIDStringType } from '../../types/UUID';
|
||||
import { isNotNil } from '../../util/isNotNil';
|
||||
import { assert } from '../../util/assert';
|
||||
import { assertDev } from '../../util/assert';
|
||||
import {
|
||||
TableIterator,
|
||||
getCountFromTable,
|
||||
|
@ -225,7 +225,7 @@ export default function updateToSchemaVersion43(
|
|||
let result = message;
|
||||
|
||||
if (groupV2Change) {
|
||||
assert(result.groupV2Change, 'Pacify typescript');
|
||||
assertDev(result.groupV2Change, 'Pacify typescript');
|
||||
|
||||
const from: UUIDStringType | undefined = getConversationUuid.get({
|
||||
conversationId: groupV2Change.from,
|
||||
|
@ -250,7 +250,7 @@ export default function updateToSchemaVersion43(
|
|||
const details = groupV2Change.details
|
||||
.map((legacyDetail, i) => {
|
||||
const oldDetail = result.groupV2Change?.details[i];
|
||||
assert(oldDetail, 'Pacify typescript');
|
||||
assertDev(oldDetail, 'Pacify typescript');
|
||||
let newDetail = oldDetail;
|
||||
|
||||
for (const key of ['conversationId' as const, 'inviter' as const]) {
|
||||
|
@ -276,7 +276,10 @@ export default function updateToSchemaVersion43(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
assert(newDetail.type === legacyDetail.type, 'Pacify typescript');
|
||||
assertDev(
|
||||
newDetail.type === legacyDetail.type,
|
||||
'Pacify typescript'
|
||||
);
|
||||
newDetail = {
|
||||
...omit(newDetail, key),
|
||||
[newKey]: newValue,
|
||||
|
@ -319,7 +322,7 @@ export default function updateToSchemaVersion43(
|
|||
});
|
||||
const oldMember =
|
||||
result.invitedGV2Members && result.invitedGV2Members[i];
|
||||
assert(oldMember !== undefined, 'Pacify typescript');
|
||||
assertDev(oldMember !== undefined, 'Pacify typescript');
|
||||
|
||||
if (!uuid) {
|
||||
logger.warn(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue