TypeScript exports issue while returning workerpools
beckend opened this issue · 1 comments
beckend commented
Exported variable 'getWorkers' has or is using name 'WorkerPool' from external module "/home/admin/Coding/project/node_modules/threads/dist/master/pool" but cannot be named.
import { cpus } from 'node:os'
import { Pool, Worker, spawn } from 'threads'
import { TWorker as TWorkerGeneral } from '../workers/general'
const getWorkers = async () => {
const cpuCores = cpus.length
const optionsPool = {
concurrency: cpuCores,
size: cpuCores,
}
const [general] = await Promise.all([
Pool(
() => spawn<TWorkerGeneral>(new Worker('../workers/general')),
optionsPool,
),
])
return {
general,
}
}
export type TWorkers = Awaited<typeof getWorkers>
Need to export https://github.com/andywer/threads.js/blob/master/src/master/pool.ts#L114 but that needs to be your decision.
nicolasnieto92 commented
same here