Git Product home page Git Product logo

Comments (19)

thesayyn avatar thesayyn commented on May 25, 2024 1

Hey @CMCDragonkai. in lock file we have ^3.8.3 and i think it ought to work with 4.x.x.

But we have something else to fix here. as far as i can see that you are trying to use this with other plugins. I guess you understood the plugin wrong. You don't need any other JS related plugins if you are using this plugin.

so instead of you way you should use it like this;

protoc --proto_path=proto/schemas --ts_out="proto/ts" ./proto/schemas/*.proto

it will generate everything to the 'proto/ts' directory. you can import those files and they are ready to use.
keep in mind that in that directory theres .ts files instead of .d.ts files which means they contain all the necessary runtime code to run.
I would like assist you further if you can't get out of this situation.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024 1

Hey @paul-pop. I'll try to release it today.

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

Using latest typescript 4.1.3. Is this compatible with the latest typescript?

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

Wait are you saying protoc-gen-grpc is not needed?

That tool is provided by the grpc-node package.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

Wait are you saying protoc-gen-grpc is not needed?

That tool is provided by the grpc-node package.

Exactly. This plugin will also generate service classes if your proto file contains any rpcs.

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

Hi @thesayyn can you update the typescript to be 4.x.x or allow the major version to vary?

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

How does?

protoc --proto_path=proto/schemas --ts_out="proto/ts" ./proto/schemas/*.proto

Know about the plugin at all?

Do we need to use $(which protoc-gen-ts)?

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

So I got super confused. https://github.com/thesayyn/protoc-gen-ts/blob/master/src/package.json <- this is the actual package.json.

But we are using protoc from grpc-tools. I'm not sure if your protoc mentioned above is from upstream protobuf or something else.

Furthermore it's not really clear how protoc is meant to know about protoc-gen-ts.

from protoc-gen-ts.

robert-cronin avatar robert-cronin commented on May 25, 2024

Hey @CMCDragonkai. in lock file we have ^3.8.3 and i think it ought to work with 4.x.x.

But we have something else to fix here. as far as i can see that you are trying to use this with other plugins. I guess you understood the plugin wrong. You don't need any other JS related plugins if you are using this plugin.

so instead of you way you should use it like this;

protoc --proto_path=proto/schemas --ts_out="proto/ts" ./proto/schemas/*.proto

it will generate everything to the 'proto/ts' directory. you can import those files and they are ready to use.
keep in mind that in that directory theres .ts files instead of .d.ts files which means they contain all the necessary runtime code to run.
I would like assist you further if you can't get out of this situation.

I am now confused as well, using the command you suggested results in a generation of .d.ts files not .ts files:

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ ls ./src/proto/ts

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ protoc --proto_path=src/proto/schemas --ts_out="src/proto/ts" src/proto/schemas/Agent.proto 

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ ls ./src/proto/ts
Agent_grpc_pb.d.ts  Agent_pb.d.ts

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

Hi @thesayyn can you update the typescript to be 4.x.x or allow the major version to vary?

I got a relocation thing going on so i won't be able to work on this for a month or so. it would be great if you could send a PR for it.
Happy to send feedback and get it merged and released.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

How does?

protoc --proto_path=proto/schemas --ts_out="proto/ts" ./proto/schemas/*.proto

Know about the plugin at all?

Do we need to use $(which protoc-gen-ts)?

First: So when you install this plugin globally through npm i -g protoc-gen-ts it installs the plugin to a global location which in turn will be available as a command. Normally after a global installation you can test if the plugin installed by running protoc-gen-ts command in your terminal. Though the plugin is not ought to work standalone. It has to be invoked by the protoc compiler.

Answer to the question "how the compiler know about the plugin" is pretty simple.
when you invoke the compiler like
protoc --ts_out the compiler find every option that ends with *_out and then looks up to the path to find a command that matches string where the wilcard is. So in this case the compiler will look up for --*_out options and will eventually find --ts_out and then will look up to the PATH variable to find a command that matches the pattern protoc-gen-* which is in this case protoc-gen-ts.
What happens here is that you have implicitly requested the outputs from the protoc-gen-ts plugin.

Second: I'm don't think that you need to run which command if you don't have duplicate commands which is not possible in unix like systems.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

Hey @CMCDragonkai. in lock file we have ^3.8.3 and i think it ought to work with 4.x.x.
But we have something else to fix here. as far as i can see that you are trying to use this with other plugins. I guess you understood the plugin wrong. You don't need any other JS related plugins if you are using this plugin.
so instead of you way you should use it like this;
protoc --proto_path=proto/schemas --ts_out="proto/ts" ./proto/schemas/*.proto
it will generate everything to the 'proto/ts' directory. you can import those files and they are ready to use.
keep in mind that in that directory theres .ts files instead of .d.ts files which means they contain all the necessary runtime code to run.
I would like assist you further if you can't get out of this situation.

I am now confused as well, using the command you suggested results in a generation of .d.ts files not .ts files:

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ ls ./src/proto/ts

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ protoc --proto_path=src/proto/schemas --ts_out="src/proto/ts" src/proto/schemas/Agent.proto 

AD+rcronin9@DESKTOP-GTR8EMA MINGW64 ~/Documents/github/js-polykey (polykey-app-bugs)
$ ls ./src/proto/ts
Agent_grpc_pb.d.ts  Agent_pb.d.ts

I suspect that you have already installed improbable-eng/ts-protoc-gen globally. If you did, you need to remove it first because when you are using this plugin, you don't need anything else.

Can you share the output of npm ls -g --depth=0 with me so that i can understand your problem better?

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

I still get the same error:

[nix-shell:~/Projects/js-polykey]$ npm install --save-dev protoc-gen-ts
npm WARN [email protected] requires a peer of acorn@^6.0.0 || ^7.0.0 || ^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/[email protected] requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/[email protected] requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 1 package from 1 contributor and audited 1328 packages in 6.22s

63 packages are looking for funding
  run `npm fund` for details

found 10109 vulnerabilities (7191 low, 3 moderate, 2915 high)
  run `npm audit fix` to fix them, or `npm audit` for details

[nix-shell:~/Projects/js-polykey]$ protoc \
$>   --proto_path=src/proto/schemas \
$>   --ts_out="src/proto/js" \
$>   ./src/proto/schemas/*.proto
/home/cmcdragonkai/Projects/js-polykey/node_modules/typescript/lib/typescript.js:12449
        return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
                     ^

TypeError: Cannot read property 'hasOwnProperty' of null
    at Object.isNodeArray (/home/cmcdragonkai/Projects/js-polykey/node_modules/typescript/lib/typescript.js:12449:22)
    at createNodeArray (/home/cmcdragonkai/Projects/js-polykey/node_modules/typescript/lib/typescript.js:20812:25)
    at Object.createCallExpression (/home/cmcdragonkai/Projects/js-polykey/node_modules/typescript/lib/typescript.js:22099:95)
    at Object.createCall (/home/cmcdragonkai/Projects/js-polykey/node_modules/typescript/lib/typescript.js:3022:29)
    at createToObject (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:49:14)
    at createMessage (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:1016:5)
    at processMessageDescriptor (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:1545:5)
    at processProtoDescriptor (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:1590:12)
    at main (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:1680:24)
    at Object.<anonymous> (/home/cmcdragonkai/Projects/js-polykey/node_modules/protoc-gen-ts/index.js:1765:1)
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

Note that the protoc is coming from grpc-tools https://github.com/grpc/grpc-node/tree/master/packages/grpc-tools

Are you assuming normal upstream protoc?

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

Even if I use upstream protoc, the same error occurs.

from protoc-gen-ts.

CMCDragonkai avatar CMCDragonkai commented on May 25, 2024

I don't have any other ts generator...

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

I will quickly take a look at this.

Sorry i was out of work for a while.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

We have landed a fix for this on master which will be available soon.

from protoc-gen-ts.

paul-pop avatar paul-pop commented on May 25, 2024

@thesayyn any chance you can trigger a 0.3.5 release with this fix?

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 25, 2024

Hey everyone, 0.3.5 has landed and must have fixed this problem already.

I was busy moving to another country.

Feel free to reopen if it keep happening

from protoc-gen-ts.

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.