Typescript errors in node_modules package with "export * as" syntax

Viewed 2164

I'm working on a Typescript NodeJS project that uses multiple Google Cloud client libraries. I want to use ES6 imports for these client libraries so I can use Intellisense in VS Code. However, when I use ES6 imports I get the following issues when trying to compile 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. ```

Are there any changes I need to make to my tsconfig to fix this?

Thanks!

1 Answers

If you're seeing this in your GCloud builds the fix in my case was updating Typescript from 3.7.2 to 4.1.3 - from my understanding any version 3.9+ should work fine.

Related