Giter Club home page Giter Club logo

Comments (8)

wilk avatar wilk commented on August 25, 2024 17

Yeah, sure!
I'll rewrite microjob in Typescript so it will be available for typescripter!

from microjob.

wilk avatar wilk commented on August 25, 2024 10

@nomeyer thank you for using it!
Sorry for the delay: microjob has been rewritten in TS in version 0.2.0 πŸŽ‰

I invite you all to try it and to open new issues and PRs!

from microjob.

wilk avatar wilk commented on August 25, 2024 2

Ok, thanks, then feel free to open a new issue for the related problem πŸ’ͺ

from microjob.

nomeyer avatar nomeyer commented on August 25, 2024 1

Thanks for your quick reply πŸ™‚

If you think this should be better highlighted inside the docs, then I'll put it asap.

No I think the docs are pretty clear that one can use a sync or async function πŸ‘

My jobs are async so I was hoping to do something like this, that's why I'm trying to get async function doStuff to work. I could try to rewrite my worker without async / await but the two examples in my previous example should be equivalent πŸ€” I'll see if I can find some time for more experiments.

from microjob.

nomeyer avatar nomeyer commented on August 25, 2024

Hey @wilk, thanks for this package & being willing to rewrite it in Typescript!

I'm looking for a clarification – is it currently possible to use it with Typescript (as an untyped library), or is it just not possible before the rewrite?

I was playing around with it and I can't seem to get around this error:

ReferenceError: tslib_1 is not defined
    at anonymous (eval at parentPort.on (/app/node_modules/microjob/src/worker.js:10:5), <anonymous>:9:5)
    at __executor__ (eval at parentPort.on (/app/node_modules/microjob/src/worker.js:10:5), <anonymous>:30:3)
    at MessagePort.parentPort.on (/app/node_modules/microjob/src/worker.js:12:27)
    at MessagePort.emit (events.js:182:13)
    at MessagePort.onmessage (internal/worker.js:66:8)

Thanks!

from microjob.

motss avatar motss commented on August 25, 2024

@nomeyer I'm a TypeScript user and have tried using it with TypeScript. Do you have a reduced test case?

from microjob.

nomeyer avatar nomeyer commented on August 25, 2024

Hey @wilk, thanks a lot for that release, much appreciated 😁

Unfortunately, I'm still getting the same error (ReferenceError: tslib_1 is not defined) – does it mean anything to you?

FWIW after gradually stripping things out of my worker function I managed to get this to work:

export function doStuff(data: IStuff): Promise<IStuff> {
  console.log(data);
  return Promise.resolve(data);
}

And I get the ReferenceError: tslib_1 is not defined as soon as I add async, like so:

export async function doStuff(data: IStuff): Promise<IStuff> {
  console.log(data);
  return data;
}

from microjob.

wilk avatar wilk commented on August 25, 2024

Hi @nomeyer !

Thank you for using it and for reporting this issue!

Well, I don't understand why it's giving you that error but it makes sense using an async function instead of a sync one with a Promise.resolve call.
However, you should be able to define a doStuff sync function like so:

export function doStuff(data: IStuff): IStuff {
  console.log(data);
  return data;
}

If you think this should be better highlighted inside the docs, then I'll put it asap.

from microjob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.