From c1730e055fbf793ba226fecc9b6dea6d3d8f455f Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Mon, 3 May 2021 11:38:20 -0500 Subject: [PATCH] Remove 25 trivial WhatIsThis types --- ts/ConversationController.ts | 3 +-- ts/background.ts | 16 +++++++--------- ts/model-types.d.ts | 4 ++-- ts/models/conversations.ts | 11 +++++++---- ts/models/messages.ts | 13 ++++--------- ts/textsecure.d.ts | 2 +- ts/window.d.ts | 11 ++++------- 7 files changed, 26 insertions(+), 34 deletions(-) diff --git a/ts/ConversationController.ts b/ts/ConversationController.ts index 0a72f59c34..b14fa5137d 100644 --- a/ts/ConversationController.ts +++ b/ts/ConversationController.ts @@ -7,7 +7,6 @@ import PQueue from 'p-queue'; import dataInterface from './sql/Client'; import { ConversationModelCollectionType, - WhatIsThis, ConversationAttributesTypeType, } from './model-types.d'; import { SendOptionsType, CallbackResultType } from './textsecure/SendMessage'; @@ -724,7 +723,7 @@ export class ConversationController { async prepareForSend( id: string | undefined, - options?: WhatIsThis + options?: { syncMessage?: boolean; disableMeCheck?: boolean } ): Promise<{ wrap: ( promise: Promise diff --git a/ts/background.ts b/ts/background.ts index b4507d404b..3890bae885 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -157,9 +157,7 @@ export async function startApp(): Promise { clearSelectedMessage(); } if (userChanged) { - userChanged({ - interactionMode, - } as WhatIsThis); + userChanged({ interactionMode }); } }; window.enterMouseMode = () => { @@ -175,7 +173,7 @@ export async function startApp(): Promise { clearSelectedMessage(); } if (userChanged) { - userChanged({ interactionMode } as WhatIsThis); + userChanged({ interactionMode }); } }; @@ -195,7 +193,7 @@ export async function startApp(): Promise { // Load these images now to ensure that they don't flicker on first use window.preloadedImages = []; - function preload(list: Array) { + function preload(list: ReadonlyArray) { for (let index = 0, max = list.length; index < max; index += 1) { const image = new Image(); image.src = `./images/${list[index]}`; @@ -339,7 +337,7 @@ export async function startApp(): Promise { window.log.info('Storage fetch'); window.storage.fetch(); - function mapOldThemeToNew(theme: WhatIsThis) { + function mapOldThemeToNew(theme: Readonly) { switch (theme) { case 'dark': case 'light': @@ -372,7 +370,7 @@ export async function startApp(): Promise { 'theme-setting', window.platform === 'darwin' ? 'system' : 'light' ), - setThemeSetting: (value: WhatIsThis) => { + setThemeSetting: (value: 'light' | 'dark' | 'system') => { window.storage.put('theme-setting', value); onChangeTheme(); }, @@ -1805,7 +1803,7 @@ export async function startApp(): Promise { USERNAME, PASSWORD, mySignalingKey, - messageReceiverOptions as WhatIsThis + messageReceiverOptions ); window.textsecure.messageReceiver = messageReceiver; @@ -1814,7 +1812,7 @@ export async function startApp(): Promise { preMessageReceiverStatus = null; // eslint-disable-next-line no-inner-declarations - function addQueuedEventListener(name: WhatIsThis, handler: WhatIsThis) { + function addQueuedEventListener(name: string, handler: WhatIsThis) { messageReceiver.addEventListener(name, (...args: Array) => eventHandlerQueue.add(async () => { try { diff --git a/ts/model-types.d.ts b/ts/model-types.d.ts index 646b82149e..810513a60f 100644 --- a/ts/model-types.d.ts +++ b/ts/model-types.d.ts @@ -140,12 +140,12 @@ export type MessageAttributesType = { attachments: Array; preview: Array; sticker: WhatIsThis; - sent_at: WhatIsThis; + sent_at: number; sent_to: Array; unidentifiedDeliveries: Array; contact: Array; conversationId: string; - recipients: Array; + recipients: Array; reaction: WhatIsThis; destination?: WhatIsThis; destinationUuid?: string; diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 9d065032b4..e6549e3305 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -3547,7 +3547,7 @@ export class ConversationModel extends window.Backbone } async getSendMetadata( - options: { syncMessage?: string; disableMeCheck?: boolean } = {} + options: { syncMessage?: boolean; disableMeCheck?: boolean } = {} ): Promise { const { syncMessage, disableMeCheck } = options; @@ -4227,7 +4227,7 @@ export class ConversationModel extends window.Backbone async markRead( newestUnreadDate: number, providedOptions: { readAt?: number; sendReadReceipts: boolean } - ): Promise { + ): Promise { const options = providedOptions || {}; window._.defaults(options, { sendReadReceipts: true }); @@ -5048,7 +5048,10 @@ export class ConversationModel extends window.Backbone return `mute(${this.get('id')})`; } - async notify(message: WhatIsThis, reaction?: WhatIsThis): Promise { + async notify( + message: Readonly, + reaction?: WhatIsThis + ): Promise { // As a performance optimization don't perform any work if notifications are // disabled. if (!window.Whisper.Notifications.isEnabled) { @@ -5296,7 +5299,7 @@ window.Whisper.ConversationCollection = window.Backbone.Collection.extend({ this.generateLookups(this.models); }, - generateLookups(models: Array) { + generateLookups(models: ReadonlyArray) { models.forEach(model => { const e164 = model.get('e164'); if (e164) { diff --git a/ts/models/messages.ts b/ts/models/messages.ts index def9a7c367..1a508ddd4d 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -3541,9 +3541,7 @@ export class MessageModel extends window.Backbone.Model { // GroupV1 if (!isGroupV2 && dataMessage.group) { const pendingGroupUpdate = []; - const memberConversations: Array< - typeof window.WhatIsThis - > = await Promise.all( + const memberConversations: Array = await Promise.all( dataMessage.group.membersE164.map((e164: string) => window.ConversationController.getOrCreateAndWait( e164, @@ -3815,10 +3813,7 @@ export class MessageModel extends window.Backbone.Model { }); } - window.MessageController.register( - message.id, - message as typeof window.WhatIsThis - ); + window.MessageController.register(message.id, message); conversation.incrementMessageCount(); window.Signal.Data.updateConversation(conversation.attributes); @@ -4102,7 +4097,7 @@ export class MessageModel extends window.Backbone.Model { } } -window.Whisper.Message = MessageModel as typeof window.WhatIsThis; +window.Whisper.Message = MessageModel; window.Whisper.Message.getLongMessageAttachment = ({ body, @@ -4137,7 +4132,7 @@ window.Whisper.Message.updateTimers = () => { window.Whisper.MessageCollection = window.Backbone.Collection.extend({ model: window.Whisper.Message, - comparator(left: typeof window.WhatIsThis, right: typeof window.WhatIsThis) { + comparator(left: Readonly, right: Readonly) { if (left.get('received_at') === right.get('received_at')) { return (left.get('sent_at') || 0) - (right.get('sent_at') || 0); } diff --git a/ts/textsecure.d.ts b/ts/textsecure.d.ts index fe0037bf98..bf5fa4d34a 100644 --- a/ts/textsecure.d.ts +++ b/ts/textsecure.d.ts @@ -85,7 +85,7 @@ export type TextSecureType = { EventTarget: typeof EventTarget; MessageReceiver: typeof MessageReceiver; AccountManager: WhatIsThis; - MessageSender: WhatIsThis; + MessageSender: typeof MessageSender; SyncRequest: typeof SyncRequest; }; diff --git a/ts/window.d.ts b/ts/window.d.ts index b1ab77e15d..cc0a0018a8 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -150,7 +150,7 @@ declare global { enterMouseMode: () => void; getAccountManager: () => AccountManager | undefined; getAlwaysRelayCalls: () => Promise; - getBuiltInImages: () => Promise>; + getBuiltInImages: () => Promise>; getCallRingtoneNotification: () => Promise; getCallSystemNotification: () => Promise; getConversations: () => ConversationModelCollectionType; @@ -175,8 +175,8 @@ declare global { showCallingPermissionsPopup: (forCamera: boolean) => Promise; i18n: LocalizerType; isActive: () => boolean; - isAfterVersion: (version: WhatIsThis, anotherVersion: string) => boolean; - isBeforeVersion: (version: WhatIsThis, anotherVersion: string) => boolean; + isAfterVersion: (version: string, anotherVersion: string) => boolean; + isBeforeVersion: (version: string, anotherVersion: string) => boolean; isFullScreen: () => boolean; isValidGuid: (maybeGuid: string | null) => boolean; isValidE164: (maybeE164: unknown) => boolean; @@ -328,10 +328,7 @@ declare global { stickerId: number ) => Promise; deletePackReference: (id: string, packId: string) => Promise; - downloadEphemeralPack: ( - packId: string, - key: WhatIsThis - ) => Promise; + downloadEphemeralPack: (packId: string, key: string) => Promise; downloadQueuedPacks: () => void; downloadStickerPack: ( id: string,