我刚刚在pacakge.json中添加了"@google-cloud/logging-winston":"2.1.0",
,并且在编译时出现以下错误。我偶尔在其他Google库中也看到过这种情况,其根本原因很可能是来自protobuf定义的自动生成的类型在堆栈中更深层次。
../node_modules/@google-cloud/logging/build/proto/logging.d.ts:1434:32 - error TS2304: Cannot find name 'Long'.
1434 line?: (number|Long|null);
~~~~
../node_modules/@google-cloud/logging/build/proto/logging.d.ts:1453:38 - error TS2304: Cannot find name 'Long'.
1453 public line: (number|Long);
~~~~
../node_modules/@google-cloud/logging/build/proto/logging.d.ts:1543:39 - error TS2304: Cannot find name 'Long'.
1543 requestSize?: (number|Long|null);
~~~~
../node_modules/@google-cloud/logging/build/proto/logging.d.ts:1549:40 - error TS2304: Cannot find name 'Long'.
1549 responseSize?: (number|Long|null);
~~~~
../node_modules/@google-cloud/logging/build/proto/logging.d.ts:1576:42 - error TS2304: Cannot find name 'Long'.
1576 cacheFillBytes?: (number|Long|null);
答案 0 :(得分:2)
在解决此问题之前,这是我的解决方法。
"long":"4.0.0",
"@types/long":"4.0.0",
{
"compilerOptions": {
...
"types": [
...
"long"
],
...
}