node.js - 使用 "export * as"语法的node_modules软件包中的 typescript 错误

标签 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. ```

我需要对tsconfig进行任何更改以解决此问题吗?
谢谢!

最佳答案

如果您在GCloud构建中看到此问题,那么在我的案例中,此修复程序是将Typescript从3.7.2更新到4.1.3-从我的理解来看,任何3.9+版本都可以正常工作。

关于node.js - 使用 "export * as"语法的node_modules软件包中的 typescript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63477857/

相关文章:

node.js - 如何在 Microsoft Bot Framework 上通过 ID 获取用户电子邮件?

node.js - 无法在 typescript 构建中包含 .key 文件

node.js - 2018 年,谷歌的一位技术主管表示,他们正在 64 位系统上的 V8 中解决 "support buffers way beyond 4GiB"。那发生了吗?

node.js - Chrome 扩展程序中的 Origin header

javascript - Angular2 从服务调用组件

typescript - 如何在 TypeScript 中定义具有任意数量的某种类型属性的接口(interface)

node.js - 通过 node.js 在当前 shell session 中设置 GOOGLE_APPLICATION_CREDENTIALS

javascript - 我可以在不编写循环的情况下声明嵌套在对象集合中的值数组吗?

html - 从 TypeScript 中的行 ID 获取表行索引

angular - 两次执行 promise 时“无法读取未定义的属性”