//... cut out of `first.pb.ts`
import { Foo, FooJSON } from "./second.pb"; // <---- these names conflict with the interfaces below
//========================================//
// Types //
//========================================//
export interface SomeRpcRequest {
id: Foo;
}
export interface SomeRpcResponse {
foo: Foo;
}
export interface Foo {
id: string;
}
//... end cut
These types and imports are also present when I just emit typescript declarations as well. I don't have a clear suggestion how to rewrite imports, maybe do something like import { Foo as second_pb_Foo } from "./second.pb"? I'm assuming that doing a glob import * as second from "./second.pb" might have implications for treeshaking or whatever, but I haven't read much about that so I can't say for sure. Anyways, I hope this helps!
I've made an example repo demonstrating the problem: https://github.com/pwalker/twirpscript_package_name_repro
The gist is this, if I import another proto file and there is a message name collision the generated code produces a typescript error:
And the generated typescript fragment:
These types and imports are also present when I just emit typescript declarations as well. I don't have a clear suggestion how to rewrite imports, maybe do something like
import { Foo as second_pb_Foo } from "./second.pb"
? I'm assuming that doing a globimport * as second from "./second.pb"
might have implications for treeshaking or whatever, but I haven't read much about that so I can't say for sure. Anyways, I hope this helps!