You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello all - I am folowing the Connect docs to implement a gRPC client to hit another service I have, and it looks like I am following it to the T, but getting type errors when i import my service.
BackfillOrchestrator, which is a service generated via buf generate is giving me a type error in the index.ts file
// shadow-protos/services/backfill-orchestrator/v1/service_connect.ts/** * @generated from service xyz.shadow.services.backfill_orchestrator.v1.BackfillOrchestrator */exportconstBackfillOrchestrator={typeName: "xyz.shadow.services.backfill_orchestrator.v1.BackfillOrchestrator",methods: {/** * @generated from rpc xyz.shadow.services.backfill_orchestrator.v1.BackfillOrchestrator.CreateBackfillJob */createBackfillJob: {name: "CreateBackfillJob",I: CreateBackfillJobRequest,O: CreateBackfillJobResponse,kind: MethodKind.Unary,},
...
}
// index.tsimport{TriggerAllHourlyExportWorkflowExecutionsResponse}from"@repo/shadow-protos/services/backfill-orchestrator/v1/service_pb";import{BackfillOrchestrator}from"@repo/shadow-protos/services/backfill-orchestrator/v1/service_connect";import{createConnectTransport}from"@connectrpc/connect-web";import{createPromiseClient}from"@connectrpc/connect";exportasyncfunctiontriggerAllHourlyBackfills(): Promise<TriggerAllHourlyExportWorkflowExecutionsResponse>{consttransport=createConnectTransport({baseUrl: "https://localhost:50052",});constclient=createPromiseClient(BackfillOrchestrator,transport);// let res = await client.triggerAllHourlyExportWorkflowExecutions({});}
The error from BackfillOrchestrator is:
Argument of type '{ readonly typeName: "xyz.shadow.services.backfill_orchestrator.v1.BackfillOrchestrator"; readonly methods: { readonly createBackfillJob: { readonly name: "CreateBackfillJob"; readonly I: typeof CreateBackfillJobRequest; readonly O: typeof CreateBackfillJobResponse; readonly kind: any; }; ... 6 more ...; readonly tr...' is not assignable to parameter of type 'ServiceType'.
Types of property 'methods' are incompatible.
Type '{ readonly createBackfillJob: { readonly name: "CreateBackfillJob"; readonly I: typeof CreateBackfillJobRequest; readonly O: typeof CreateBackfillJobResponse; readonly kind: any; }; ... 6 more ...; readonly triggerAllHourlyExportWorkflowExecutions: { ...; }; }' is not assignable to type '{ [localName: string]: MethodInfo<AnyMessage, AnyMessage>; }'.
Property 'createBackfillJob' is incompatible with index signature.
Type '{ readonly name: "CreateBackfillJob"; readonly I: typeof CreateBackfillJobRequest; readonly O: typeof CreateBackfillJobResponse; readonly kind: any; }' is not assignable to type 'MethodInfo<AnyMessage, AnyMessage>'.
Type '{ readonly name: "CreateBackfillJob"; readonly I: typeof CreateBackfillJobRequest; readonly O: typeof CreateBackfillJobResponse; readonly kind: any; }' is not assignable to type 'MethodInfoBiDiStreaming<AnyMessage, AnyMessage>'.
The types returned by 'I.fromBinary(...)' are incompatible between these types.
Type 'CreateBackfillJobRequest' is missing the following properties from type 'AnyMessage': equals, clone, fromBinary, fromJson, and 6 more.
generated CreateBackfillJobRequest via buf generate
syntax="proto3";
packagexyz.shadow.libs.common.v1.types;
messageChain {
// Required.ChainIdchain=1;
// Required.NetworkIdnetwork=2;
}
enumChainId {
UnknownChain=0;
Ethereum=1;
Optimism=2;
Base=3;
}
enumNetworkId {
UnknownNetwork=0;
Mainnet=1;
Goerli=2;
}
messageFork {
// Required.stringid=1;
// Optional. Default version is 0.uint64version=2;
}
// Right half-open interval denoting a list of blocks.messageBlockRange {
// Start of the range (inclusive).uint64start=1;
// End of the range (exclusive).uint64end=2;
}
Hey Brenner, I copied your TypeScript config into our example and don't see an issue.
The cause of the error message you see is:
Type 'CreateBackfillJobRequest' is missing the following properties from type 'AnyMessage': equals, clone, fromBinary, fromJson, and 6 more.
This indicates that the base class Message from @bufbuild/protobuf could not be resolved when the compiler tries to compile the generated code.
You can remove the comment @ts-nocheck from the generated code to see an error message explaining why. (We generate the annotation for better BC, but it can be disable, see the documentation.)
I'm going to close this, but please feel free to re-open with a reproducible example.
If you are using next.js, this is a known issue, see vercel/next.js#59744. If you are not using next.js, the same issue likely applies to turbopack.
The ecosystem is in a bad state right now: You have to use the .js extension in imports for TypeScript's modern ESM resolution logic, but bundlers are slow to catch up.
The option import_extension=.ts or import_extension=none should both work in this case.
Describe the bug
Hello all - I am folowing the Connect docs to implement a gRPC client to hit another service I have, and it looks like I am following it to the T, but getting type errors when i import my service.
BackfillOrchestrator
, which is a service generated viabuf generate
is giving me a type error in theindex.ts
fileAny idea on what's going on?
The error from
BackfillOrchestrator
is:generated
CreateBackfillJobRequest
viabuf generate
protofiles
Environment:
18.19.0
The text was updated successfully, but these errors were encountered: