threads.js icon indicating copy to clipboard operation
threads.js copied to clipboard

Expose types so typescript users can use them

Open linonetwo opened this issue 3 years ago • 3 comments

https://github.com/andywer/threads.js/blob/762337476637f83f38876b9f25ec5e5816c47594/src/master/spawn.ts#L23-L25

I need to write this:

private wikiWorkers: Record<string, ArbitraryThreadType> = {};

but Module '"threads"' has no exported member 'ArbitraryThreadType'.ts(2305)

linonetwo avatar May 03 '21 08:05 linonetwo

Using PromiseValue<ReturnType<typeof spawn>> now.

Needs import { PromiseValue } from 'type-fest';

linonetwo avatar May 03 '21 08:05 linonetwo

import { WorkerEvent, WorkerEventType } from 'threads/dist/types/master';

will cause

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/types/master' is not defined by "exports" in /Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/threads/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)

use import type { WorkerEvent } from 'threads/dist/types/master'; solves this.

linonetwo avatar May 03 '21 11:05 linonetwo

Hey @linonetwo! Sorry for the late reply.

Can you please list all the types that you would need to have exposed? Makes it much easier to discuss (if at all necessary) and implement. Feel free to open a PR, too.

andywer avatar May 09 '21 19:05 andywer