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 generates invalid typescript when used on Windows #1275

Open
oceanusxiv opened this issue Aug 7, 2019 · 7 comments
Open

pbts generates invalid typescript when used on Windows #1275

oceanusxiv opened this issue Aug 7, 2019 · 7 comments

Comments

@oceanusxiv
Copy link

protobuf.js version: 6.8.8

When on Windows, pbts generates invalid typescript even though pbjs is outputting the correct annotated js file.

Using the test proto from the protobufjs repo here.

The expected typescript file would contain

public static verify(message: { [k: string]: any }): (string|null);

as seen here.

Instead the type file contains

public static verify(message: [ 'object' ].<string, any>): (string|null);

which is invalid typescript code.

The commands I ran for the conversion were

yarn run pbjs -t static-module -w commonjs -o protobufjs/comments.js protos/comments.proto
yarn run pbts -o protobufjs/comments.d.ts protobufjs/comments.js
@medns
Copy link

medns commented Aug 8, 2019

I have the same issue

@FrobtheBuilder
Copy link

This happens to me too.

@FrobtheBuilder
Copy link

By the way, I think this is a compatibility issue with the latest version of Node. I'm using 12.4.0, and pbts hasn't really been updated at all in a year or so. The dependencies that it installs aren't at all related to parsing the actual jsdocs, so I don't think that's it either. I'm going to try on some previous versions and see which one works in a bit.

@JiangJie
Copy link

By the way, I think this is a compatibility issue with the latest version of Node. I'm using 12.4.0, and pbts hasn't really been updated at all in a year or so. The dependencies that it installs aren't at all related to parsing the actual jsdocs, so I don't think that's it either. I'm going to try on some previous versions and see which one works in a bit.

Waiting for your good news.

@sw-clough
Copy link

I was getting the same error when using node 12.8.0. I've now rolled-back to the latest LTS release, 10.16.3, and now my files are correct.

@chris-grabcad
Copy link

I'm using protobuf.js in an electron app - which we're currently upgrading to v5 of electron, which has a fixed compatible version of node 12.0.0 (electron v7 uses 12.4.0).

So workarounds like using an older version of node don't really work for us.

I took a look at the way pbts works and it seems to rely heavily on jsdoc to do most of the heavy lifting, by upgrading the version of jsdoc used by this module to use v3.6.3 of jsdoc seemed to work just fine for me. (I made a local clone of this repo and referred to it via ../protobuf.js in my package.json.

I will make a PR into this repo when I've finished my current thread.

@chris-grabcad
Copy link

PR is here #1338

akrolsmir added a commit to akrolsmir/streamlit that referenced this issue Jun 22, 2020
akrolsmir added a commit to streamlit/streamlit that referenced this issue Jun 22, 2020
* Change Husky pre-commit hook to work on Windows

Source: typicode/husky#281

* Update protobufjs to resolve TS compilation on Windows

Source: protobufjs/protobuf.js#1275

* Switch to a patched version of hard-source

aurelia/webpack-plugin#136

* Use `env` instead of `export` for Windows compatibility

https://stackoverflow.com/questions/25112510/how-to-set-environment-variables-from-within-package-json
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

No branches or pull requests

6 participants