protobuf.js version: 6.8.8
// file: test.proto without filed 'package'
syntax = "proto3";
enum OuterEnum {
FOO = 1;
BAR = 2;
}
```bash
// run commond
./node_modules/.bin/pbjs -t static-module -w commonjs -o compiled.js test.proto
./node_modules/.bin/pbts -o compiled.d.ts compiled.js
**Expect Result for file: compiled.d.ts**
```typescript
enum OuterEnum {
FOO = 1,
BAR = 2
}
Real Result for file: compiled.d.ts ❌❌
import * as $protobuf from "protobufjs";
// file: test.proto with filed 'package'
syntax = "proto3";
package test; // add
enum OuterEnum {
FOO = 1;
BAR = 2;
}
Real Result for file: compiled.d.ts ✅✅
import * as $protobuf from "protobufjs";
/** Namespace test. */
export namespace test {
/** OuterEnum enum. */
enum OuterEnum {
FOO = 1,
BAR = 2
}
}
Is it necessary to add field 'package' for enum ?
I face with the same problem.
When I don't write 'package' in a proto file, the generated d.ts file has some grammatical errors (e.g. a class is extended from a certain interface, but the interface isn't declared) in addition to lack of enum.
+1
I think I ran into this issue recently as well and tracked it down to an issue handling enums in jsdoc. I just created a pull request to fix the issue, but it may be awhile before it's merged in (assuming it's accepted): https://github.com/jsdoc/jsdoc/pull/1686
[email protected] will cause the enum problem, so I solved it by:
cd node_modules/protobufjs
sed -i "s/\"jsdoc\": \".*\"/\"jsdoc\": \"3.5.5\"/" package.json
cd cli
npm install [email protected]
Most helpful comment
+1