Skip to content
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

pbts doesn't generate enum typings when the enum is defined after its use #1342

Closed
schiffermtq opened this issue Jan 10, 2020 · 6 comments
Closed

Comments

@schiffermtq
Copy link
Contributor

schiffermtq commented Jan 10, 2020

protobuf.js version: 6.8.8

Take the following .proto file:

syntax = "proto3";

message Test {
	Status status = 0;
}

enum Status {
	STATUS_ERROR = 0;
	STATUS_OK = 1;
}

With the following commands:

pbjs -t static-module -w es6 -o ./test.js ./test.proto
pbts -o ./test.d.ts ./test.js

The generated .d.ts file will be unusable, as it references the type Status, buts its definition is missing. Using commonjs instead of es6 yields the same results.

Reversing the order of the definitions leads to a different result: while a Status definition is emitted, now ITest is missing instead.

@schiffermtq
Copy link
Contributor Author

schiffermtq commented Jan 17, 2020

The issue seems to be fixed in the protobuf.js master, when can we expect a new release?

@schiffermtq
Copy link
Contributor Author

It seems the issue occurs depending on the versions of installed dependencies of the CLI:

  • When I clone the protobuf.js repo and run npm install in both the repository root and the cli subdir, correct definitions are emitted
  • When I leave out any of the npm install runs or use npm or yarn to install protobuf.js from the NPM registry or directly from the Git repo, pbjs/pbts will install additional dependencies on first run. Whenever this happens, the installation emits broken Typescript declarations.

schiffermtq added a commit to schiffermtq/protobuf.js that referenced this issue Jan 20, 2020
pbts currently doesn't work with jsdoc 3.6.x and will emit broken
definitions when trying to use it.

As the toplevel package-lock.json is not respected by `npm install` as
executed by the CLI utils, fix the jsdoc version to 3.5.5 in
package.json.

Fixes protobufjs#1342
@EliCDavis
Copy link

Running into same issues

@EliCDavis
Copy link

Moreover, it seems that messages defined after an enum declaration do not have appropriate interfaces. It's utterly broken and is preventing successful builds

@jsbrucker
Copy link

@dcodeIO did #1356 resolve this issue?

@arcaneMage01
Copy link

arcaneMage01 commented Sep 2, 2021

protobuf version 6.9.1 resolved this issue

@dcodeIO dcodeIO closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants