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

Cannot find name 'Long' #1071

Closed
Panayiotou-P opened this issue Jun 15, 2018 · 4 comments
Closed

Cannot find name 'Long' #1071

Panayiotou-P opened this issue Jun 15, 2018 · 4 comments
Labels

Comments

@Panayiotou-P
Copy link

Panayiotou-P commented Jun 15, 2018

protobuf.js version: 6.8.4

After generating code using pbjs and pbjs:

node_modules/protobufjs/bin/pbjs --force-long -t static-module -w commonjs -o info.protobuf.js info.proto
node_modules/protobufjs/bin/pbts -o info.d.ts info.protobuf.js

I have included the long and @types/long in my package.json file:
"long": "^4.0.0",
"@types/long": "^4.0.0",

In my tsconfig.json file I have the following:
{ "compileOnSave": false, "compilerOptions": { ... "types": [ "node_modules/long" ], "typeRoots": [ "node_modules/@types", ] }, "include": [ "src/**/*", "src/assets/proto/*.d.ts" ], "files": [ ... ] }

I import the generated typescript file in my component but when I try to compile I get the following error in
info.d.ts: Cannot find name 'Long'

How can I resolve this issue?
Thanks in advance

@Panayiotou-P Panayiotou-P changed the title CAnnot fina name 'Long' Cannot find name 'Long' Jun 15, 2018
@chloe2018s
Copy link

hi did you resolve this issue eventually ? got the same issue here. thx

@Panayiotou-P
Copy link
Author

Panayiotou-P commented Aug 22, 2018

What worked for me was to add the following method in my app.component.ts (Angular application)

declare var require: any

export class AppComponent {
ngOnInit(){
var $protobuf = require("protobufjs/minimal");
var Long = require('long');
$protobuf.util.Long = Long;
$protobuf.configure();
}
}

@JustinBeckwith
Copy link
Contributor

Greetings! I'm pretty sure we fixed this over in #1166. We will look into cutting a release next!

@esilkensen
Copy link
Contributor

Hi @JustinBeckwith, thanks for the fix! Do you know when this might make it into a release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants