googleapis / nodejs-common

🚀🐢 A set of classes and utilities used in Google npm modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't import 0.18.2 in a .ts file

nolanmar511 opened this issue · comments

Environment details

  • OS:
  • Node.js version:
  • npm version:
  • @google-cloud/common version: 0.18.2

Steps to reproduce

I tried to import the module like import * as common from '@google-cloud/common'; in ts/src/index.ts of
https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs, and saw the following output during typescript compilation, which seem to come from this module

node_modules/@google-cloud/common/build/src/service-object.d.ts:29:107 - error TS2694: Namespace 'request' has no exported member 'Response'.

29 export declare type GetMetadataCallback = (err: Error | null, metadata?: Metadata | null, apiResponse?: r.Response) => void;
                                                                                                             ~~~~~~~~


node_modules/@google-cloud/common/build/src/service-object.d.ts:65:77 - error TS2694: Namespace 'request' has no exported member 'Response'.

65     (err: ApiError | null, instance?: ServiceObject | null, apiResponse?: r.Response): void;
                                                                               ~~~~~~~~


node_modules/@google-cloud/common/build/src/service-object.d.ts:68:41 - error TS2694: Namespace 'request' has no exported member 'Response'.

68     (err: Error | null, apiResponse?: r.Response): void;
                                           ~~~~~~~~


node_modules/@google-cloud/common/build/src/service-object.d.ts:157:71 - error TS2694: Namespace 'request' has no exported member 'Response'.

157     setMetadata(metadata: {}, callback?: (err: Error | null, resp?: r.Response) => void): void;
                                                                          ~~~~~~~~


node_modules/@google-cloud/common/build/src/service-object.d.ts:167:58 - error TS2694: Namespace 'request' has no exported member 'Response'.

167     request_(reqOpts: DecorateRequestOptions): Promise<r.Response | r.Request>;
                                                             ~~~~~~~~


node_modules/@google-cloud/common/build/src/service-object.d.ts:177:57 - error TS2694: Namespace 'request' has no exported member 'Response'.

177     request(reqOpts: DecorateRequestOptions): Promise<r.Response>;
                                                            ~~~~~~~~


node_modules/@google-cloud/common/build/src/service.d.ts:84:58 - error TS2694: Namespace 'request' has no exported member 'Response'.

84     request_(reqOpts: DecorateRequestOptions): Promise<r.Response>;
                                                            ~~~~~~~~


node_modules/@google-cloud/common/build/src/service.d.ts:94:57 - error TS2694: Namespace 'request' has no exported member 'Response'.

94     request(reqOpts: DecorateRequestOptions): Promise<r.Response>;
                                                           ~~~~~~~~


node_modules/@google-cloud/common/build/src/service.d.ts:103:63 - error TS2694: Namespace 'request' has no exported member 'Response'.

103     requestStream(reqOpts: DecorateRequestOptions): Promise<r.Response>;
                                                                  ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:2:23 - error TS2688: Cannot find type definition file for 'duplexify'.

2 /// <reference types="duplexify" />
                        ~~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:22:28 - error TS7016: Could not find a declaration file for module 'duplexify'. '/usr/local/google/home/nolanmar/cloud-profiler-nodejs-working/cloud-profiler-nodejs/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';`

22 import * as duplexify from 'duplexify';
                              ~~~~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:29:13 - error TS2694: Namespace 'request' has no exported member 'Response'.

29     resp: r.Response;
               ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:110:17 - error TS2694: Namespace 'request' has no exported member 'Response'.

110     response: r.Response;
                    ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:163:18 - error TS2694: Namespace 'request' has no exported member 'Response'.

163     response?: r.Response;
                     ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:174:18 - error TS2694: Namespace 'request' has no exported member 'Response'.

174     response?: r.Response;
                     ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:178:52 - error TS2694: Namespace 'request' has no exported member 'Response'.

178     (err: Error | null, body: ResponseBody, res: r.Response): void;
                                                       ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:195:35 - error TS2694: Namespace 'request' has no exported member 'Response'.

195     shouldRetryFn?: (response?: r.Response) => boolean;
                                      ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:218:44 - error TS2694: Namespace 'request' has no exported member 'Response'.

218     handleResp(err: Error | null, resp?: r.Response | null, body?: ResponseBody, callback?: BodyResponseCallback): void;
                                               ~~~~~~~~


node_modules/@google-cloud/common/build/src/util.d.ts:227:45 - error TS2694: Namespace 'request' has no exported member 'Response'.

227     parseHttpRespMessage(httpRespMessage: r.Response): ParsedHttpRespMessage;

Yuck. This is because request and duplexify are exported types :( In the short term - you should be able to npm install --save-dev @types/request @types/duplexify

I will start working on a better fix now though.