Open theabhinavdas opened 1 month ago
On further exploration, we may console.log(Hatchet);
to see the Hatchet object looks like:
{
ConcurrencyLimitStrategy: [Getter],
WorkflowConcurrency: [Getter],
HatchetTimeoutSchema: [Getter],
CreateWorkflowSchema: [Getter],
CreateRateLimitSchema: [Getter],
CreateStepSchema: [Getter],
Context: [Getter],
Worker: [Getter],
APIContracts: [Getter],
Api: [Getter],
AdminClient: [Getter],
default: [class HatchetClient]
}
It actually doesn't have an init()
function but we see that HatchetClient
(at ./node_modules/@hatchet-dev/typescript-sdk/clients/hatchet-client/hatchet-client.d.ts
) does have a static init(...)
function and that's coming from default
.
So it seems like using Hatchet.default.init(...)
fixes this issue. Will wait for authors to verify and close.
Yep! I'm dealing with the same problem, even when writing TS file and building with esbuild...
This was my solution using it inside a remix project (vite)
import HatchetModule from '@hatchet-dev/typescript-sdk'
// Use type assertion to access the default export
const Hatchet = (HatchetModule as any).default || HatchetModule
Firstly, thank you for this amazing project!
I'm trying to use hatchet-typescript in a JS project by installing it via
npm i @hatchet-dev/typescript-sdk
, then importingHatchet
withimport Hatchet from "@hatchet-dev/typescript-sdk";
and finally initializing likeconst hatchet = Hatchet.init(config);
. This gives me the following error:TypeError: Hatchet.init is not a function
Is this not the right way to use this SDK in a JS project?