feat: add "strictNullChecks"

This commit is contained in:
Adhiraj Singh
2022-07-08 10:38:25 +05:30
parent 7426b7aa2f
commit 40a1e268aa
42 changed files with 350 additions and 339 deletions

View File

@@ -12,7 +12,7 @@ export interface GroupMetadata {
subjectOwner?: string
/** group subject modification date */
subjectTime?: number
creation: number
creation?: number
desc?: string
descOwner?: string
descId?: string

View File

@@ -71,7 +71,8 @@ export type SocketQueryOptions = SocketSendMessageOptions & {
requiresPhoneConnection?: boolean
}
export type LegacySocketConfig = CommonSocketConfig<LegacyAuthenticationCreds> & {
export type LegacySocketConfig = CommonSocketConfig & {
auth?: LegacyAuthenticationCreds
/** max time for the phone to respond to a connectivity test */
phoneResponseTimeMs: number
/** max time for WA server to respond before error with 422 */

View File

@@ -22,7 +22,7 @@ export type WAMediaUpload = Buffer | { url: URL | string } | { stream: Readable
/** Set of message types that are supported by the library */
export type MessageType = keyof proto.Message
export type DownloadableMessage = { mediaKey?: Uint8Array, directPath?: string, url?: string }
export type DownloadableMessage = { mediaKey?: Uint8Array | null, directPath?: string | null, url?: string | null }
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | undefined
@@ -37,7 +37,7 @@ export interface WAUrlInfo {
'canonical-url': string
'matched-text': string
title: string
description: string
description?: string
jpegThumbnail?: Buffer
}
@@ -182,7 +182,7 @@ export type MediaGenerationOptions = {
mediaUploadTimeoutMs?: number
}
export type MessageContentGenerationOptions = MediaGenerationOptions & {
getUrlInfo?: (text: string) => Promise<WAUrlInfo>
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>
}
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent

View File

@@ -8,9 +8,7 @@ import { MediaConnInfo } from './Message'
export type WAVersion = [number, number, number]
export type WABrowserDescription = [string, string, string]
export type CommonSocketConfig<T> = {
/** provide an auth state object to maintain the auth state */
auth?: T
export type CommonSocketConfig = {
/** the WS url to connect to WA */
waWebSocketUrl: string | URL
/** Fails the connection if the socket times out in this interval */

View File

@@ -7,7 +7,7 @@ export type ConnectionState = {
connection: WAConnectionState
/** the error that caused the connection to close */
lastDisconnect?: {
error: Error
error: Error | undefined
date: Date
}
/** is this a new login */

View File

@@ -17,7 +17,9 @@ import { CommonSocketConfig } from './Socket'
export type MessageRetryMap = { [msgId: string]: number }
export type SocketConfig = CommonSocketConfig<AuthenticationState> & {
export type SocketConfig = CommonSocketConfig & {
/** provide an auth state object to maintain the auth state */
auth: AuthenticationState
/** By default true, should history messages be downloaded and processed */
downloadHistory: boolean
/** transaction capability options for SignalKeyStore */
@@ -67,18 +69,16 @@ export type WABusinessHoursConfig = {
export type WABusinessProfile = {
description: string
email: string
email: string | undefined
business_hours: {
timezone?: string
config?: WABusinessHoursConfig[]
business_config?: WABusinessHoursConfig[]
}
website: string[]
categories: {
id: string
localized_display_name: string
}[]
category?: string
wid?: string
address?: string
}