ts-proto icon indicating copy to clipboard operation
ts-proto copied to clipboard

Feature request: autogenerate index files

Open willclarktech opened this issue 4 years ago • 4 comments

With protobuf.js we used to generate all our type definitions in one big file and then we could easily re-export everything from a single index file. With ts-proto we now have nested files reflecting the structure very nicely, but manually creating index files that reflect this structure is going to be a pain. It would be nice to have an option for ts-proto to automatically generate index files that make each subdirectory a module that just re-exports everything from the files/subdirectories it contains.

willclarktech avatar Feb 11 '21 12:02 willclarktech

I worry about the inevitable namespace collisions from messages with the same name being in different proto files, but otherwise yeah this seems like a good idea.

stephenh avatar Feb 12 '21 05:02 stephenh

The solution can be more simpler I think : one file per proto package => one typescript namespace per package

alexisvisco avatar Feb 26 '22 17:02 alexisvisco

@alexisvisco can you clarify that with a concrete example?

stephenh avatar Feb 26 '22 17:02 stephenh

@alexisvisco please don't use Typescript namespaces. They're a completely unnecessarily relic since ES6 Modules, and support for them is very patchy.

kallangerard avatar Mar 16 '22 03:03 kallangerard

An outputIndex option was added in #821

stephenh avatar Aug 22 '23 02:08 stephenh