Nodejs-pubsub: Can't use the library in projects that build with skipLibCheck: false

Created on 7 Mar 2019  路  15Comments  路  Source: googleapis/nodejs-pubsub

Environment details

  • OS: Linux
  • Node.js version: 10.15.1
  • npm version: rush 5.5.3, using pnpm 2.16.0
  • @google-cloud/pubsub version: 0.27.0 / 0.27.1

Steps to reproduce

  1. Import @google-cloud/pubsub into a TypeScript project
  2. Don't enable "skipLibCheck": true (or explicitly set it to false in your tsconfig.json
  3. Try to build

Resulting errors (I've trimmed some very long paths that rush+pnpm generates):

<long-rush-path-1>/@google-cloud/pubsub/build/proto/iam.d.ts(2,23): error TS2307: Cannot find module 'long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/iam.d.ts(3452,40): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/iam.d.ts(3455,40): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/iam.d.ts(3483,46): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/iam.d.ts(3486,46): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(2,23): error TS2307: Cannot find module 'long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7060,40): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7063,40): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7091,46): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7094,46): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7687,31): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7703,37): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7957,31): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/proto/pubsub.d.ts(7973,37): error TS2304: Cannot find name 'Long'.
<long-rush-path-1>/@google-cloud/pubsub/build/src/message-queues.d.ts(19,24): error TS7016: Could not find a declaration file for module 'p-defer'. '<long-rush-path-4>/p-defer/index.js' implicitly has an 'any' type.
  Try `npm install @types/p-defer` if it exists or add a new declaration (.d.ts) file containing `declare module 'p-defer';`
<long-rush-path-2>/google-gax/build/src/streaming.d.ts(32,28): error TS7016: Could not find a declaration file for module 'duplexify'. '<long-rush-path-5>/duplexify/index.js' implicitly has an 'any' type.
  Try `npm install @types/duplexify` if it exists or add a new declaration (.d.ts) file containing `declare module 'duplexify';`
<long-rush-path-3>/grpc/index.d.ts(2,55): error TS7016: Could not find a declaration file for module 'protobufjs'. '<long-rush-path-6>/protobufjs/dist/protobuf.js' implicitly has an 'any' type.
  Try `npm install @types/protobufjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'protobufjs';`
TypeScript: 17 semantic errors
TypeScript pubsub p2 bug

Most helpful comment

Been a bit kooky on my end, but I just tried updating one of our projects to 0.28.1 and setting skipLibCheck: false again, and the errors related to PubSub are indeed gone, thank you :grinning:

All 15 comments

@callmehiphop was this covered in #536?

@JustinBeckwith I think so, but it would probably be best if @mgabeler-lee-6rs could let us know after we cut our next release.

@mgabeler-lee-6rs I just published a new release (0.28), would you mind upgrading and testing to see if your issue still persists?

536 looks promising, and I think it definitely helped, but it doesn't quite solve the issue. I still have the errors below in a consumer project when skipLibCheck is set false in tsconfig.json.

I think what's left that needs fixing is:

  1. This package needs @types/long
  2. google-gax needs @types/duplexify, and this package needs to pull that update
  3. grcp needs an updated protobufjs, and this package needs to pull that update
../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/iam.d.ts:2:23 - error TS2307: Cannot find module 'long'.

2 import * as long from "long";
                        ~~~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/iam.d.ts:3452:40 - error TS2304: Cannot find name 'Long'.

3452             positiveIntValue?: (number|Long|null);
                                            ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/iam.d.ts:3455:40 - error TS2304: Cannot find name 'Long'.

3455             negativeIntValue?: (number|Long|null);
                                            ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/iam.d.ts:3483:46 - error TS2304: Cannot find name 'Long'.

3483             public positiveIntValue: (number|Long);
                                                  ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/iam.d.ts:3486:46 - error TS2304: Cannot find name 'Long'.

3486             public negativeIntValue: (number|Long);
                                                  ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:2:23 - error TS2307: Cannot find module 'long'.

2 import * as long from "long";
                        ~~~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7060:40 - error TS2304: Cannot find name 'Long'.

7060             positiveIntValue?: (number|Long|null);
                                            ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7063:40 - error TS2304: Cannot find name 'Long'.

7063             negativeIntValue?: (number|Long|null);
                                            ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7091:46 - error TS2304: Cannot find name 'Long'.

7091             public positiveIntValue: (number|Long);
                                                  ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7094:46 - error TS2304: Cannot find name 'Long'.

7094             public negativeIntValue: (number|Long);
                                                  ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7687:31 - error TS2304: Cannot find name 'Long'.

7687             seconds?: (number|Long|null);
                                   ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7703:37 - error TS2304: Cannot find name 'Long'.

7703             public seconds: (number|Long);
                                         ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7957:31 - error TS2304: Cannot find name 'Long'.

7957             seconds?: (number|Long|null);
                                   ~~~~

../../common/temp/node_modules/.registry.npmjs.org/@google-cloud/pubsub/0.28.0/node_modules/@google-cloud/pubsub/build/proto/pubsub.d.ts:7973:37 - error TS2304: Cannot find name 'Long'.

7973             public seconds: (number|Long);
                                         ~~~~

../../common/temp/node_modules/.registry.npmjs.org/google-gax/0.25.4/node_modules/google-gax/build/src/streaming.d.ts:32:28 - error TS7016: Could not find a declaration file for module 'duplexify'. '/home/mgl/src/event-ingestion/common/temp/node_modules/.registry.npmjs.org/duplexify/3.7.1/node_modules/duplexify/index.js' implicitly has an 'any' type.
  Try `npm install @types/duplexify` if it exists or add a new declaration (.d.ts) file containing `declare module 'duplexify';`

32 import * as Duplexify from 'duplexify';
                              ~~~~~~~~~~~

../../common/temp/node_modules/.registry.npmjs.org/grpc/1.19.0/node_modules/grpc/index.d.ts:2:55 - error TS7016: Could not find a declaration file for module 'protobufjs'. '/home/mgl/src/event-ingestion/common/temp/node_modules/.registry.npmjs.org/protobufjs/5.0.3/node_modules/protobufjs/dist/protobuf.js' implicitly has an 'any' type.
  Try `npm install @types/protobufjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'protobufjs';`

2   import { Message, Service as ProtobufService } from "protobufjs";
                                                        ~~~~~~~~~~~~


Found 16 errors.

@mgabeler-lee-6rs thanks for the speedy reply!

@JustinBeckwith what is the latest news for https://github.com/googleapis/nodejs-datastore/pull/358? I assume whatever the resolution is there, we'll want the same thing here.

I'm not going to have time to engage there for the next few days. @callmehiphop can you try adding skipLibCheck and types: ['node'] to the existing system test, and seeing where it goes? Worst case, we add code to the generated d.ts for now while we wait for the fix to land in pbts.

@JustinBeckwith those options already exist in the system test, but neither my local machine or CI can replicate the error. I'm just going to bite the bullet and manually edit the generated files until we get a proper fix in pbts.

NB: I realized I got the title of this issue confused / backwards, though the description was correct

@mgabeler-lee-6rs oh whoops, looks like we had it configured wrong in that case! Thanks for the update!

@mgabeler-lee-6rs just published a patch release. I think this might be the one 馃

Been kind of quiet here, so I'm going to close this one out. If the issue re-surfaces, please let us know!

Been a bit kooky on my end, but I just tried updating one of our projects to 0.28.1 and setting skipLibCheck: false again, and the errors related to PubSub are indeed gone, thank you :grinning:

@mgabeler-lee-6rs awesome, thanks for letting us know!

/me looks to see what we did to fix it

I believe it was #541

Was this page helpful?
0 / 5 - 0 ratings