Protobuf.js: protobuf have issue with typescript long : Cannot find name 'Long'

Created on 21 Aug 2018  路  3Comments  路  Source: protobufjs/protobuf.js

I'm new to protobuf. I'm using "protobufjs": "^6.8.8" for generating typescript. And imported this generated file to my component.spec.ts , then got compilation error when run ng serve
[ERROR] target/generated-sources-js/xxx.d.ts(4253,40): error TS2304: Cannot find name 'Long'.

I included the "@types/long": "^4.0.0", "long": "^4.0.0", in my package.json dependencies. Still got the same error.

Please advise. Many thanks

bug

Most helpful comment

Is there a plan to release a new version anytime soon? This bug exists in 6.8.8, and the fix was never released.

All 3 comments

You need to add the following configuration

{ "compilerOptions": { ... "types": [ ..., "Long"] } ... }

in the tsconfig.jsonfile

compilerOptions.types add "Long" to array

Greetings! I think we fixed this over in #1166

Is there a plan to release a new version anytime soon? This bug exists in 6.8.8, and the fix was never released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mj-mehdizadeh picture mj-mehdizadeh  路  5Comments

jarvanxing picture jarvanxing  路  4Comments

spiderkeys picture spiderkeys  路  5Comments

filipednb picture filipednb  路  5Comments

RP-3 picture RP-3  路  4Comments