-
Notifications
You must be signed in to change notification settings - Fork 349
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
TS error if .proto file has the same message name as imported #896
Comments
Huh, yeah, we're supposed to have the infra in place to support this...the ts-poet codegen library knows about "symbols defined in this file" as well as "symbols imported from other files" and will rename the imports if it detects a conflict. I.e. that is why It seems like that did not work for The code that seems https://github.com/stephenh/ts-proto/blob/main/src/main.ts#L875 Which eventually gets here: https://github.com/stephenh/ts-proto/blob/main/src/types.ts#L586 And should be getting If you'd like to track down where that is going wrong, that would be great! Thanks! |
+1 Noticing the same problem. It now fails to compile because the toJSON and fromJSON fail to use the alias'ed import as the type. I notice the problem even in v1.151.1. |
I'm having the same issue, it's easy to add a case to fail the tests, you just need to add this message to
The generated interface is incorrect:
otherSimple should be Simple3 | undefined instead of Simple | undefined Edit: I did some testing and the commit that breaks the gen is indeed this one: 1405d4b . I will try to understand what changed there |
I've opened the PR to fix this issue here. It seems that the issue was the check to emit a warning, which transforms the Code object. I've also tested it with the example provided by skycrazyk and it generates the code correctly now. |
🎉 This issue has been resolved in version 1.156.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Dependencies
Problem description
There is
common/common.proto
which hasFindOptions
messageand
items/items.proto
which hasFindOptions
too. Alsoitems.proto
importscommon.proto
and usescommon.FindOptions
message inside their ownFindOptions
message.Finally during the build process we have TS error
(spoiler) config/dist/items/items.ts(1511,27): error TS2345: Argument of type 'import("/builds/perxis/perxis- js/config/dist/items/items").FindOptions' is not assignable to parameter of type 'import("/builds/perxis/perxis- js/config/dist/common/common").FindOptions'.
The problem that final
items.d.ts
file doesn't importsFindOptions
fromcommon
at allso inside
items.d.ts
FindOptions
interface refers on themselfI have similar story with
Filter
message, which also exists in both files, but insideitems.proto
it is used withrepeated
, and in finalitems.d.ts
it imported correctly, with rename toFilter1
as you can see on the image above.The text was updated successfully, but these errors were encountered: