Skip to content
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

node.js and typescript #98

Open
LoungeFlyZ opened this issue Feb 12, 2016 · 18 comments
Open

node.js and typescript #98

LoungeFlyZ opened this issue Feb 12, 2016 · 18 comments
Labels
enhancement New feature or request javascript P3 triaged Issue has been triaged

Comments

@LoungeFlyZ
Copy link

Great to see you have JS support for browsers and node.js. However, for those of us writing with typescript (for either browser or node.js) it would be very helpful to have a typescript definition file (.d.ts file).

Possible?

@haberman
Copy link
Member

Yes, that would be very welcome. @mprobst suggested to me that we could use http://github.com/angular/clutz to generate TypeScript interfaces from our Closure-annotated source code.

@haberman haberman added javascript enhancement New feature or request labels Feb 12, 2016
@mprobst
Copy link

mprobst commented Feb 15, 2016

@haberman IMHO it might be a bit too much effort for a project that's not already using Closure to set up the infrastructure to run clutz (java, Closure, build system deps). I think it might still be worth having a compiler (mode) that produces .d.ts files.

@myitcv
Copy link

myitcv commented Feb 15, 2016

@mprobst 👍 - we're currently generating .d.ts files using a separate compilation process.

@LoungeFlyZ
Copy link
Author

@myitcv are there any public pointers to how we could do something like that?

@myitcv
Copy link

myitcv commented Apr 28, 2016

@LoungeFlyZ - nothing public yet. Not for lack of want or trying... just that other things are getting in the way at the moment.

@pleerock
Copy link

pleerock commented Jul 2, 2016

+1 for typescript

@tamird
Copy link

tamird commented Aug 27, 2016

If there are any clutz + protobuf experts out there, I'm currently slogging through setting that up for CockroachDB. Your help would be appreciated over in angular/clutz#334!

@alexpyzhianov
Copy link

Any progress on this so far?

@Brahmasmi
Copy link

Would it be possible for the Protocol Buffers team to share their plans for adding typescript support?
Specifically,

  1. Generating .d.ts (aka Typescript definition files) from the compiler, as pointed out by @mprobst - tracked here.
  2. Supporting protobufs in the browser (which are then imported into a client-side typescript framework) - javascript part tracked via Proto3 integration with JS #91.
  3. Documenting the workflow for a novice/beginner on the browser side - again tracked via Proto3 integration with JS #91.

The base case for the above request is that of using protobufs in Angular typescript. In case the team wants me to open separate tracking bugs for typescript for points 2) and 3) above, please let me know.

@pshields
Copy link

@mprobst does your team have a vision for how this should work? It seems like the strategy for generating TypeScript protobuf code and consuming it client-side projects is still not really documented or implemented yet. Could someone with a grasp of what effort remains explain what still needs to be done?

I'm trying to consume generated protobuf code for an Angular/Bazel/Closure app written in TypeScript, and I think protobuf support is one of the last missing pieces. I noted in https://github.com/bazelbuild/rules_typescript/issues/116 that adding a closure_js_proto_library rule as a dependency on a ts_library doesn't currently work--but I'm not sure if fixing that rule is the best approach, or if the protobuf or rules_typescript contributors have a different approach in mind.

@mprobst
Copy link

mprobst commented Jan 15, 2018

@pshields we don't have a good open source answer. Internally, we use the proto->JS generator, and then use https://github.com/angular/clutz to convert that to TypeScript definitions. But you're right, that hasn't been open sourced, so it doesn't work with closure_js_proto_library.

I also suspect that if you're not using that generator for other reasons, you might be better off with a different solution. If I remember correctly, protobufjs has support for generating TypeScript code, but I've never used it.

/CC @alexeagle who might have something cooking here.

@alexeagle
Copy link

I'd rather not use Closure codegen if we want TypeScript types. Clutz is complex, and I don't want to ever introduce it under Bazel, because I don't know of any Bazel users who continue development of Closure JS code along with their TypeScript.

bazelbuild/rules_typescript#61 is what I intend to do, which would generate .d.ts from .proto. Bazel users should adopt the best of the existing open source tools to solve a given problem, not adopt the Google-authored tool by default.

@iKBAHT
Copy link

iKBAHT commented May 30, 2018

Any progress on this in 2k18?

@alexeagle
Copy link

Under Bazel, we have a ts_proto_library rule in http://tsetse.info/api/protobufjs/ts_proto_library.html
which generates the .d.ts files for typechecking. It's very simple to add this as a dependency of a ts_library.

This uses https://github.com/dcodeIO/protobuf.js#pbts-for-typescript under the covers. If you don't use Bazel, you could use that library directly to generate .d.ts files, assuming you use the corresponding generator for the .js runtime files. (That's because client generation has some degrees of freedom in how they name the api methods, and the .d.ts needs to match)

This is not the only way to do protocol buffers, but it's the one we are supporting under the Angular toolchain for now.

@BSBandme BSBandme added the P3 label Jun 8, 2018
@tmc
Copy link

tmc commented Jul 8, 2018

For what it's worth I have a typescript generator here: https://godoc.org/github.com/tmc/grpcutil/protoc-gen-tstypes

@Sieabah
Copy link

Sieabah commented Jun 13, 2019

Considering Google has mentioned NestJS and is building Angular in Typescript I think it'd only make sense for protobuf to support some form of Typescript natively?

Has there been any change since last year about the stance this project has on Typescript?

@thesayyn
Copy link

thesayyn commented Dec 8, 2021

We have a plugin that is maintained by me and people from the community;

https://github.com/thesayyn/protoc-gen-ts

@acozzette acozzette transferred this issue from protocolbuffers/protobuf May 16, 2022
@dibenede dibenede added the triaged Issue has been triaged label Sep 23, 2022
@dibenede
Copy link
Contributor

This is a reasonable, but substantial FR that we are unlikely to get to soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript P3 triaged Issue has been triaged
Projects
None yet
Development

No branches or pull requests