You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by joeflatt September 18, 2021
Hi,
I'm new to this so not sure if it's a bug or a known issue that has a workaround.
I compile against a large set of proto files that contain a message named Object. I don't have any control over the proto files themselves. The generated typescript code won't compile because it makes use of static methods on JavaScript's Object class (i.e. Object.defineProperty).
Here's how I'm using protobuf-ts:
npx protoc --ts_out src/ --ts_opt generate_dependencies --proto_path apis/ find apis -name '*.proto'
Thanks!
The easiest fix seems to be an adding Object to the list of reserved type names here:
Keywords are much less likely to change than objects in the global scope, so we should only escape keywords, and use globalThis for objects in global scope.
Discussed in #160
Originally posted by joeflatt September 18, 2021
Hi,
I'm new to this so not sure if it's a bug or a known issue that has a workaround.
I compile against a large set of proto files that contain a message named Object. I don't have any control over the proto files themselves. The generated typescript code won't compile because it makes use of static methods on JavaScript's Object class (i.e. Object.defineProperty).
Here's how I'm using protobuf-ts:
npx protoc --ts_out src/ --ts_opt generate_dependencies --proto_path apis/
find apis -name '*.proto'
Thanks!
The easiest fix seems to be an adding
Object
to the list of reserved type names here:protobuf-ts/packages/plugin/src/code-gen/local-type-name.ts
Line 6 in 2803503
Alternatively, change our access on
Object
toglobalThis.Object
.The text was updated successfully, but these errors were encountered: