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

2.0.3 version of ms-rest-js causes issues when we try to prepack sdks that take a dependency on that version #367

Closed
amarzavery opened this issue Jul 15, 2019 · 5 comments · Fixed by #419
Labels

Comments

@amarzavery
Copy link
Contributor

amarzavery commented Jul 15, 2019

amarz-MBP:arm-kusto amarz$npm run prepack

> @azure/arm-kusto@2.0.1 prepack /Users/amarz/sdk/azure-sdk-for-js/sdk/kusto/arm-kusto
> npm install && npm run build

audited 72 packages in 0.576s
found 0 vulnerabilities


> @azure/arm-kusto@2.0.1 build /Users/amarz/sdk/azure-sdk-for-js/sdk/kusto/arm-kusto
> tsc -p tsconfig.json && rollup -c rollup.config.js && npm run minify

node_modules/@azure/ms-rest-js/es/lib/fetchHttpClient.d.ts:7:70 - error TS2304: Cannot find name 'RequestInit'.

7   abstract prepareRequest(httpRequest: WebResource): Promise<Partial<RequestInit>>;
                                                                       ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/fetchHttpClient.d.ts:9:25 - error TS2304: Cannot find name 'RequestInfo'.

9   abstract fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                          ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/fetchHttpClient.d.ts:9:45 - error TS2304: Cannot find name 'RequestInit'.

9   abstract fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                                              ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/fetchHttpClient.d.ts:9:67 - error TS2304: Cannot find name 'Response'.

9   abstract fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                                                                    ~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/fetchHttpClient.d.ts:11:47 - error TS2304: Cannot find name 'Headers'.

11 export declare function parseHeaders(headers: Headers): HttpHeaders;
                                                 ~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/nodeFetchHttpClient.d.ts:7:18 - error TS2304: Cannot find name 'RequestInfo'.

7     fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                   ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/nodeFetchHttpClient.d.ts:7:38 - error TS2304: Cannot find name 'RequestInit'.

7     fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                                       ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/nodeFetchHttpClient.d.ts:7:60 - error TS2304: Cannot find name 'Response'.

7     fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
                                                             ~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/nodeFetchHttpClient.d.ts:8:63 - error TS2304: Cannot find name 'RequestInit'.

8     prepareRequest(httpRequest: WebResource): Promise<Partial<RequestInit>>;
                                                                ~~~~~~~~~~~

node_modules/@azure/ms-rest-js/es/lib/webResource.d.ts:25:28 - error TS2304: Cannot find name 'Event'.

25     dispatchEvent: (event: Event) => boolean;
                              ~~~~~

node_modules/@azure/ms-rest-js/es/lib/webResource.d.ts:26:43 - error TS2304: Cannot find name 'Event'.

26     onabort: ((this: AbortSignalLike, ev: Event) => any) | null;
                                             ~~~~~

node_modules/@azure/ms-rest-js/es/lib/webResource.d.ts:27:77 - error TS2304: Cannot find name 'Event'.

27     addEventListener: (type: "abort", listener: (this: AbortSignalLike, ev: Event) => any, options?: any) => void;
                                                                               ~~~~~

node_modules/@azure/ms-rest-js/es/lib/webResource.d.ts:28:80 - error TS2304: Cannot find name 'Event'.

28     removeEventListener: (type: "abort", listener: (this: AbortSignalLike, ev: Event) => any, options?: any) => void;
                                                                                  ~~~~~


Found 13 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @azure/arm-kusto@2.0.1 build: `tsc -p tsconfig.json && rollup -c rollup.config.js && npm run minify`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @azure/arm-kusto@2.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amarz/.npm/_logs/2019-07-15T17_18_03_751Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @azure/arm-kusto@2.0.1 prepack: `npm install && npm run build`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @azure/arm-kusto@2.0.1 prepack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amarz/.npm/_logs/2019-07-15T17_18_03_777Z-debug.log
amarz-MBP:arm-kusto amarz$ 

@kpajdzik - When I look at fetchHttpClient.ts there are no imports for RequestInit, RequestInfo, etc. because in tsconfig.json in lib we include "dom".
I am not sure why tsc complains about this when i am trying to build say @azure/arm-kusto.

  • The quick fix bulb in vscode tries to import those types from "node-fetch". Which is what we don't want since fetchHttpClient is the abstract base class that is common to both node and browser scenario.
  • If I include "dom" in "lib" of @azure/arm-kusto's tsconfig then the builld is fine. Don't quite like this solution. However, I am not sure of any other way to fix this.

/cc @bterlson, @daviwil - Any idea on how to fix this?

@ejizba
Copy link

ejizba commented Jul 22, 2019

@amarzavery I ran into this as well. Any recommended workarounds?

@bterlson
Copy link
Member

bterlson commented Jul 22, 2019

@EricJizbaMSFT If you add dom to your tsconfig lib entry you should be able to build without error.

The root cause IIUC is that the lib entry in tsconfig is applied for an entire program and a library's tsconfig and your dependencies' tsconfigs are ignored. So any lib entries your library needs to build will have to be present in consumers' tsconfig else they will get errors.

The better fix is either to add a triple-slash reference to the DOM lib, or better yet, stub just the types you need in a structurally compatible way. These techniques are discussed a bit here, but the gist is: triple-slash references work nicely but behave as if the user had added that lib entry themselves (and so their whole program sees types they didn't themselves configure), while stubbing usually works best but takes work and duplicates types.

@OJezu
Copy link

OJezu commented Dec 18, 2019

This is open for half a year, forcing node typescript projects depending on azure SDKs to include "dom" in libraries. This is ridiculous, when will Microsoft do something about broken build dependencies?

I'm having this problem with @azure/core-http

node_modules/@azure/core-http/es/lib/fetchHttpClient.d.ts:7:72 - error TS2304: Cannot find name 'RequestInit'.

7     abstract prepareRequest(httpRequest: WebResource): Promise<Partial<RequestInit>>;
                                                                         ~~~~~~~~~~~

@Tatsinnit
Copy link
Member

Tatsinnit commented May 28, 2020

💡I know this is open for a while So just reiterating if anyone has definite right answer please?, but discussion above regarding DOM helped. Thanks.

What got me going is below I.e. workaround. (Mentioning if it comes handy to anyone else)

  • Temp Solution - I have included DOM in the tsconfig and that fixes the error.

Tatsinnit added a commit to Azure/vscode-aks-tools that referenced this issue May 30, 2020
Fix arm-containerservice deprecated packages build warning.

* Adding DOM as build fix, existing bug Azure/ms-rest-js#367

* Style fix: tuck away the type assertions in a named helper.
@mamtaarpit
Copy link

Wow I am using v2.0.8 but the issue is as same as previous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants