-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use google/protobuf/any.proto #39
Comments
That looks interesting :) Do you happen to be on Windows? |
yep i am using windows 10 |
Ok. I'm pretty sure that this "importPath" has windows path separators (\) that have to be swapped.
But I have to setup a test env to confirm and fix. You'll have to wait a few days... In the meantime, I can think of two workarounds:
|
it seems it need path normalization , i already tried to replace paths, but it says module not found . import { Any } from "./google/protobuf/any"; Managed to compile it with : import { Any } from "google-protobuf/google/protobuf/any_pb.js"; but don't know if it works or not because i am unable to go past this : i am trying to migrate from after reading the documentation installed and added the following call to the server. const transport = new TwirpFetchTransport({
baseUrl: "0.0.0.0:50052"
});
const client = new ProcessTypeWritesServiceClient(transport);
const payload:CreateProcessTypeInput_GRPC = {
processTypeStatus:input.processTypeStatus
}
const {response} = await client.createProcessTypeGRPC(payload);
console.log("Response! " + response) but getting : TypeError: globalThis.Headers is not a constructor at TwirpFetchTransport.unary thanks |
That should work. I guess the file is not there? Use protoc argument '--ts_opt generate_dependencies':
Are you running the twirp transport in nodejs?
|
You are right i missed the flag yes i am running it in nodejs, also installed |
Have a look here: protobuf-ts/packages/twirp-transport/clientcompat/client.ts Lines 12 to 16 in 7d0855f
And here: protobuf-ts/packages/test-generated/spec/generated-client-style-call.spec.ts Lines 3 to 6 in 7d0855f
|
i tried everything but it seems to fail on me every time. if i don't set TypeError: globalThis.Headers is not a constructor if uncomment it ,getting the following type errors. did google for it allot but i guess i am the only one getting these :( error TS2322: Type 'typeof Headers' is not assignable to type '{ new (init?: HeadersInit): Headers; prototype: Headers; }'.
The types of 'prototype.forEach' are incompatible between these types.
Type '(callback: (value: string, name: string) => void) => void' is not assignable to type '(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any) => void'.
Types of parameters 'callback' and 'callbackfn' are incompatible.
37 globalThis.Headers = Headers;
~~~~~~~~~~~~~~~~~~
is there any other way i can send calls to the server ? |
The code snippets in the comments above are part of the CI workflow. Take a step back and get Headers working as expected, see examples here: https://developer.mozilla.org/en-US/docs/Web/API/Headers The fetch API is nice and node-fetch is an excellent implementation. Once you have that working, the TypeError is either gone - or you should be confident enough to just do |
found out that the problem is not with the node-fetch lib. The export declare const Headers: (property?: string) => ParameterDecorator; and the error is always taking me to this globalThis.fetch(url, {
--
headers: createTwirpRequestHeader(new globalThis.Headers(), !!opt.sendJson, opt.meta),
--
--
}) now need to find out how do i switch this global for the protobuf-ts. |
Alright the problem with |
Fixed in v1.0.11 |
But when i am running the generator it is generating the import like :
The text was updated successfully, but these errors were encountered: