Comments (7)
Thanks for the report; kind of surprised b/c ts-proto generally tries to understand packages, although the mapping between a proto package and JS/TS module and file paths are all kind of murky. I'll try to take a look at this soon. I might get distracted reorganizing some of the test projects to make this easier to repro...
from ts-proto.
Oh wait, I see. I missed that local message Foo
when I first scanned this issue this morning.
Yeah, that will be a little bit more involved.
In theory, the ts-poet library that ts-proto uses is supposed to solve exactly this sort of "fancy auto-import" type thing, but it doesn't realize there could be local vs. imported symbol conflicts.
So, ideally getting ts-poet fixed would transitively fix this issue, although then there is a small wrinkle that ts-poet has a 3.x API out that is a fairly big breaking change from the 2.x API that ts-proto is currently using.
Basically, yeah, I see the issue, and will (likely slowly but hopefully steadily) work towards a fix.
from ts-proto.
As an update here, I implemented import collision avoidance in the latest/3.x API for ts-poet, see this test case:
https://github.com/stephenh/ts-poet/blob/master/src/index-tests.tsx#L163
Which is cool, but now means either: a) backporting that feature to the ts-poet 2.x branch that ts-proto uses (...probably easier?), or b) migrating ts-proto onto ts-poet 3.x (best for the long term and should not be hard but definitely tedious work).
If this is a big pain point/blocker for you, you could look into either of those, otherwise I'll get around to b) at some point.
from ts-proto.
Thanks, that's neat! It's not a huge pain point right now, because we can just delete the (unused) conflicting import manually. Looking forward to the fix! I think it will be useful once we generate a larger number of proto ts interfaces (right now 10-20), but eventually have 1000s of proto files in a mono repo we would like to generate ts interfaces for. Thanks, this project is great!
from ts-proto.
Hey @jeffpyke , so it took a few months, but I got around to the ts-poet upgrade, so this should be fixed now in v1.47.0. Let me know if you still see issues. Thanks!
from ts-proto.
@stephenh I'm having a similar issue with the latest version of ts-proto
. I created a sample repo to help explain. I have a proto file which imports messages from two other proto files which happen to have the same name. ts-proto
(and by extension ts-poet
) don't avoid the naming conflict so I end up with the following in my output TS file:
import { User } from "../protos/auth/types";
import { User } from "../protos/user/types";
I'll spend some time digging into the issue for a good place to resolve it, but if you have any pointers, they would be greatly appreciated!
from ts-proto.
@stezu okay, try ts-proto v1.56.0, and see if that fixes it. Thanks!
from ts-proto.
Related Issues (20)
- Add common types to their own file/export w/outputIndex option HOT 2
- Questions about defaults, optionals, arrays, null/undefined HOT 2
- Support `google.api` attributes/conventions HOT 1
- NestJS without Observables HOT 1
- meta generated for messages with oneOf properties is incorret for other properties HOT 1
- Add types for toJSON/fromJSON methods HOT 1
- TypeError on Runtime ChannelCredentials object HOT 1
- Using 'useDate=string' parameter; the response is still anticipating an object for Timestamp Wrapper
- Encode crashes on `null` object values HOT 2
- Rpc doesn't account for metadata HOT 2
- Rpc is not exported by ts-proto as it previously was HOT 6
- Generated affixes HOT 5
- Conflicting protobuf definitions when using ts-proto plugin with Buf HOT 2
- Support for proto-loader "virtual" oneof field
- Release updated ts-proto-descriptors? HOT 4
- Proto import statements not being recognized HOT 1
- Support for messages with the same name as an rpc method HOT 2
- unexpected changes in `camelToSnake()` at v1.176.1 HOT 7
- Typescript as peerDependency HOT 3
- Easier to use oneof=union generated code HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-proto.