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: Cannot find name 'Long'. #1533

Open
kherock opened this issue Jan 12, 2021 · 2 comments
Open

pbts: Cannot find name 'Long'. #1533

kherock opened this issue Jan 12, 2021 · 2 comments

Comments

@kherock
Copy link

kherock commented Jan 12, 2021

protobuf.js version: 6.10.2

This issue has been reported multiple times in #1104 #1071 #940 but were all closed with #1166. However that PR was reverted and never made it into a release. As of today, it seems like any definition file generated by pbts that references a Long type is invalid.

@toteto
Copy link

toteto commented May 28, 2022

Any updates on this issue? Are we doing something wrong that working with Long is impossible for static-module?

Using #940 gave me some hope... but it doesn't work for me.

@Goldabj
Copy link

Goldabj commented Mar 15, 2023

I've run into the same issue. I was able to figure out the root cause was that I had a dependency on a library which had a types.d.ts file generated using pbts and used protobufjs v6.11.2. But my package has a dependency on protobufjs v7.2.2.

In v7 of protobufjs, they removed @types/long and instead use long directly. However, this requires a import Long from 'long' in the generated types.d.ts file. (See the fix in v7 here). Therefore if you import a type.d.ts file without this import (which is missing on older protobufjs version generated files), then the resolution of Long fails (if using v7 protobufjs).

Your options are:

  1. Re-generate the typescript types with the version of protobufjs (or protobufjs-cli) that matches the runtime protobufjs version you are using.
  2. Downgrade your runtime dependency on protobufjs to match the version used to generate the type definitions.
  3. Add @types/long: "^4.0.1" to your package.json devDependencies section.

I went with option 3, since I depend on a handful of pbts generate packages (some on v6, others using v7) which I needed to migrate to v7 iteratively.

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

3 participants