Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use the library in projects that build with skipLibCheck: false #532

Closed
mgabeler-lee-6rs opened this issue Mar 7, 2019 · 15 comments
Closed
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. TypeScript

Comments

@mgabeler-lee-6rs
Copy link
Contributor

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
@callmehiphop callmehiphop added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. TypeScript labels Mar 7, 2019
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Mar 8, 2019
@callmehiphop callmehiphop added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Mar 8, 2019
@JustinBeckwith
Copy link
Contributor

@callmehiphop was this covered in #536?

@callmehiphop
Copy link
Contributor

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

@callmehiphop
Copy link
Contributor

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

@mgabeler-lee-6rs
Copy link
Contributor Author

#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.

@callmehiphop
Copy link
Contributor

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

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

@JustinBeckwith
Copy link
Contributor

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.

@callmehiphop
Copy link
Contributor

@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.

@mgabeler-lee-6rs mgabeler-lee-6rs changed the title Can't use the library in projects that build with skipLibCheck: true Can't use the library in projects that build with skipLibCheck: false Mar 11, 2019
@mgabeler-lee-6rs
Copy link
Contributor Author

mgabeler-lee-6rs commented Mar 11, 2019

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

@callmehiphop
Copy link
Contributor

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

@callmehiphop
Copy link
Contributor

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

@callmehiphop
Copy link
Contributor

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

@mgabeler-lee-6rs
Copy link
Contributor Author

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 😀

@callmehiphop
Copy link
Contributor

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

@JustinBeckwith
Copy link
Contributor

/me looks to see what we did to fix it

@mgabeler-lee-6rs
Copy link
Contributor Author

I believe it was #541

@google-cloud-label-sync google-cloud-label-sync bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants