使用“export * as”语法的 node_modules 包中的打字稿错误

Nie*_*sic 10 node.js typescript

我正在开发一个使用多个 Google Cloud 客户端库的 Typescript NodeJS 项目。我想对这些客户端库使用 ES6 导入,以便我可以在 VS Code 中使用 Intellisense。但是,当我使用 ES6 导入时,在尝试编译 Typescript 时会遇到以下问题:

TS1005: 'from' expected.

119 export * as protobufMinimal from 'protobufjs/minimal';
             ~~

node_modules/google-gax/build/src/fallback.d.ts:119:13 - error TS1005:
';' expected.

119 export * as protobufMinimal from 'protobufjs/minimal';
                ~~~~~~~~~~~~~~~

node_modules/google-gax/build/src/fallback.d.ts:119:29 - error TS1005:
';' expected.

119 export * as protobufMinimal from 'protobufjs/minimal';
                                ~~~~

node_modules/google-gax/build/src/fallback.d.ts:119:34 - error TS1005:
';' expected.

119 export * as protobufMinimal from 'protobufjs/minimal';
                                     ~~~~~~~~~~~~~~~~~~~~

node_modules/google-gax/build/src/index.d.ts:47:10 - error TS1005:
'from' expected.

47 export * as protobufMinimal from 'protobufjs/minimal';
            ~~

node_modules/google-gax/build/src/index.d.ts:47:13 - error TS1005: ';'
expected.

47 export * as protobufMinimal from 'protobufjs/minimal';
               ~~~~~~~~~~~~~~~

node_modules/google-gax/build/src/index.d.ts:47:29 - error TS1005: ';'
expected.

47 export * as protobufMinimal from 'protobufjs/minimal';
                               ~~~~

node_modules/google-gax/build/src/index.d.ts:47:34 - error TS1005: ';'
expected.

47 export * as protobufMinimal from 'protobufjs/minimal';
                                    ~~~~~~~~~~~~~~~~~~~~


Found 8 errors. ```
Run Code Online (Sandbox Code Playgroud)

tsconfig为了解决这个问题,我需要做任何更改吗?

谢谢!

Far*_*son 8

如果你在你的 GCloud 构建中看到这个,在我的情况下修复是将 Typescript 从 3.7.2 更新到 4.1.3 - 根据我的理解,任何 3.9+ 版本都应该可以正常工作。

  • 我的云功能文件夹中有 google-gax 文件,其中包含打字稿“version”:“3.9.10”,但我仍然遇到相同的构建错误。有什么帮助吗? (2认同)