-
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
Array message type generates invalid code on account of name collision. #927
Comments
I ran into the same issue when working with pg_query.proto from libpg_query but with |
The simple fix here would be for ts-proto to prefix all of its global variable usage with globalThis.Array.isArray(object?.array) ? object.array.map((e: any) => globalThis.Number(e)) : [] |
Hey, thanks for the report; this should be fixed in #930 ... disclaimer I did not technically add a schema with But lmk if I missed any. Another disclaimer is that the |
🎉 This issue has been resolved in version 1.158.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@stephenh Adding the test with the message types might be a good idea as the fix in #930 doesn't cover all the cases. I'm still getting errors with the latest ts-proto v.1.159.1: https://github.com/Hilzu/ts-proto-with-pg-query#ts-proto-creates-invalid-code-for-pg_queryproto
|
Ah, thanks for the report @Hilzu -- I've reopened the issue. Fwiw if you could submit a PR that repros + fixes the issue, based on the general pattern of #930 , that'd be great/really appreciated. I think you could use Thanks! |
Sure I can check it out. Should be straightforward enough. |
* fix: Support using messages called String/Boolean/Number/Array Fixes #927 * chore: bin2ts
🎉 This issue has been resolved in version 1.159.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I unfortunately am working with a schema where I have an Array message type. This causes issues with the generated code, as the Array message type that gets generated collides with the native Array type, see:
fromJSON(object: any): Whatever {
return { array: Array.isArray(object?.array) ? object.array.map((e: any) => Number(e)) : [] };
},
In this case, since I have an Array message type, that is unfortunately what is being referred to here in this code snippet. Did I miss some configuration in the docs which I can use to fix this?
The text was updated successfully, but these errors were encountered: