tsc: fix builds & fix type errors

This commit is contained in:
Rajeh Taher
2025-07-19 17:15:51 +03:00
parent 97dfccf9fe
commit 29f0ac83f8
7 changed files with 23 additions and 17 deletions
+5 -5
View File
@@ -21,19 +21,19 @@
"engine-requirements.js"
],
"scripts": {
"build:all": "tsc && typedoc",
"build:all": "yarn build && yarn build:docs",
"build:docs": "typedoc",
"build:tsc": "tsc",
"build": "tsc -P tsconfig.build.json",
"changelog:last": "conventional-changelog -p angular -r 2",
"changelog:preview": "conventional-changelog -p angular -u",
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"example": "tsx ./Example/example.ts",
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
"format": "prettier --write \"src/**/*.{ts,js,json,md}\"",
"lint": "eslint src --ext .js,.ts",
"lint": "tsc && eslint src --ext .js,.ts",
"lint:fix": "yarn format && yarn lint --fix",
"prepack": "tsc",
"prepare": "tsc",
"prepack": "yarn build",
"prepare": "yarn build",
"preinstall": "node ./engine-requirements.js",
"release": "release-it",
"test": "jest"
+3 -2
View File
@@ -4,6 +4,7 @@ import { proto } from '../../WAProto'
import { DEFAULT_CACHE_TTLS, PROCESSABLE_HISTORY_TYPES } from '../Defaults'
import type {
BotListInfo,
CacheStore,
ChatModification,
ChatMutation,
LTHashState,
@@ -73,10 +74,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
const placeholderResendCache =
config.placeholderResendCache ||
new NodeCache({
(new NodeCache<number>({
stdTTL: DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
useClones: false
})
}) as CacheStore)
if (!config.placeholderResendCache) {
config.placeholderResendCache = placeholderResendCache
+2 -2
View File
@@ -83,13 +83,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const msgRetryCache =
config.msgRetryCounterCache ||
new NodeCache({
new NodeCache<number>({
stdTTL: DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
useClones: false
})
const callOfferCache =
config.callOfferCache ||
new NodeCache({
new NodeCache<WACallEvent>({
stdTTL: DEFAULT_CACHE_TTLS.CALL_OFFER, // 5 mins
useClones: false
})
+2 -2
View File
@@ -75,7 +75,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
const userDevicesCache =
config.userDevicesCache ||
new NodeCache({
new NodeCache<JidWithDevice[]>({
stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
useClones: false
})
@@ -237,7 +237,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
}
for (const key in deviceMap) {
userDevicesCache.set(key, deviceMap[key])
userDevicesCache.set(key, deviceMap[key]!)
}
}
+3 -3
View File
@@ -27,7 +27,7 @@ export function makeCacheableSignalKeyStore(
): SignalKeyStore {
const cache =
_cache ||
new NodeCache({
new NodeCache<SignalDataTypeMap[keyof SignalDataTypeMap]>({
stdTTL: DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
useClones: false,
deleteOnExpire: true
@@ -42,7 +42,7 @@ export function makeCacheableSignalKeyStore(
const data: { [_: string]: SignalDataTypeMap[typeof type] } = {}
const idsToFetch: string[] = []
for (const id of ids) {
const item = cache.get<SignalDataTypeMap[typeof type]>(getUniqueId(type, id))
const item = cache.get<SignalDataTypeMap[typeof type]>(getUniqueId(type, id)) as any
if (typeof item !== 'undefined') {
data[id] = item
} else {
@@ -68,7 +68,7 @@ export function makeCacheableSignalKeyStore(
let keys = 0
for (const type in data) {
for (const id in data[type as keyof SignalDataTypeMap]) {
cache.set(getUniqueId(type, id), data[type as keyof SignalDataTypeMap]![id])
cache.set(getUniqueId(type, id), data[type as keyof SignalDataTypeMap]![id]!)
keys += 1
}
}
+6 -1
View File
@@ -1,6 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false
"noEmit": false,
"allowImportingTsExtensions": false,
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"outDir": "lib",
"declaration": true,
"sourceMap": true,
"declarationMap": true,
@@ -35,5 +35,5 @@
"checkJs": false
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "src/Tests/*"]
"exclude": ["node_modules"]
}