-
Notifications
You must be signed in to change notification settings - Fork 351
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
Support interface-only output #14
Comments
If you feel its something you could release then that would be great, otherwise I don't mind doing it but right now - I am not able to build it because of the missing pbjs under build. There are some other minimal things also which I think can fixed very easily, my typescript is complaining about implicit "any". I will paste the output here. ( i ran tsc manually but if you do an npm install, it does the same as you have a "prepare" script in the package.json)
|
Ah, sorry, no,
I'm not against a sort of The Observable change also seems fine, as long as both your proposed |
+1 for interface only. Here is the scenario, we use protobuf in server side and it will return either protobuf or json result. In the client side, we want to use json query and result in type script and don’t want to manually maintain the interface. So we want to generate the interface and keep it update during build. And we want to have an undefined value type in interface |
Ah sure, that makes sense. I've not personally used that setup before, so I'm not 100% sure the TS types would 100% match what the server-side JSON result is, but it seems reasonable. (And if it's not 100% aligned, we could probably nudge ts-proto to make it line up.) Is that something you're fine with prototyping on your own, and could submit a PR? That would be great if so. I think you probably just want to add an "if interfaceOnly then don't generate service/etc./etc" check to this method: https://github.com/stephenh/ts-proto/blob/master/src/main.ts#L51 |
This is implemented on #28 The following options provide for interface-only output:
Until this is merged you can use |
Thanks @n3rdyme ! This is merged into master and will be in the next release. |
Hi,
I forked it but i notice there is a missing directory under build called pbjs, i figured this was pbjs from npm so I replaced it but it missing some things - is this a custom build ? Can you include it in repo ?
I stumbled onto this package by accident and its almost what I need. I just want simple TS files.
I was hoping to be able to extend the
To contain useObservables: boolean - as I notice you are returning a promise - but i would love to have an observable returned here - i thought adding an option would be great.. I am using NestJS - and my services return observables. (there is a link here - if you are not aware of it ( https://docs.nestjs.com/microservices/grpc )
Also another option like
or something similar, basically meaning that it just creates the interfaces and nothing else - let me show you an example...
I will show you my proto file and what I prefer (just a minimal output using only interfaces etc) and the generated code that ts-proto produces :-
What I would like, notice it's minimal and also I return an observable rather than a promise, I don't have any ctx etc... Just the interfaces for the types and the interface for the service
Here is what ts-proto produces
The text was updated successfully, but these errors were encountered: