grpc_tools_node_protoc_ts icon indicating copy to clipboard operation
grpc_tools_node_protoc_ts copied to clipboard

Add `export {}` to empty files

Open floitsch opened this issue 4 years ago • 1 comments

When creating empty files (like when there is no service), the typescript files should still have an export {} so that the files are recognized as modules. Otherwise export * from './empty won't work.

See https://github.com/microsoft/TypeScript/issues/46343

floitsch avatar Oct 13 '21 15:10 floitsch

I made some tests, if the proto file contains no services:

  • empty proto file
  • only with some message

Generated *_grpc_pb.js contains only one line:

// GENERATED CODE -- NO SERVICES IN PROTO

So I think your requirement requires https://github.com/grpc/grpc-node to make the change first. I mean they need to patch the command line tool to output sth like:

// *_grpc_pb.js

// GENERATED CODE -- NO SERVICES IN PROTO
exports = {};

Changes on this d.ts tools can't change the js source code.

BTW the version of command line tool of mine in using is: [email protected].

agreatfool avatar Oct 14 '21 05:10 agreatfool