-
Notifications
You must be signed in to change notification settings - Fork 55
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
@types/node lib definitions getting referenced for projects targeting browser #462
Comments
@mashenoy thank you for reporting the issue. While we are looking into this, I am curious about what you use @azure/ms-rest-js for. Also please note that this library is now in maintenance mode. If you only need the HttpClient, we have created a new package with a lot of improvements: https://www.npmjs.com/package/@azure/core-rest-pipeline |
I'm confused about your repro, since it explicitly imports When I set up a small example project locally that simply uses
I can use it without dragging in import { WebResource, DefaultHttpClient } from "@azure/ms-rest-js";
export async function exampleFunction() {
const x = new WebResource("https://bing.com");
const client = new DefaultHttpClient();
const result = await client.sendRequest(x);
// is typed as `any`
return result.readableStreamBody;
} Also, you said you are targeting ES5, but your repro explicitly targets ES6 and includes that in its lib definitions? |
Apologies ES6/ES5 was typo so please disregard that. @xirzec: I tried the snippet you shared, If I don't have However, let's say node_modules/@types/node/index.d.ts |
@jeremymeng - Thanks for letting me know on the support for @azure/ms-rest-js. |
Is it pulling that in from transitive dependencies or are you saying for other reasons you need to have your package.json pull in Either way, the recommended approach is to manually specify This will give you full control over which types are considered. |
@xirzec - Yes that was my understanding as well and I should be able to use |
This is surprising to me as well. It seems like there is a very big hammer that might solve this problem: https://www.typescriptlang.org/tsconfig/#noResolve The downside is that it disables all triple slash imports, so you end up having to specify everything you need (including module imports, which is unfortunate.) @DanielRosenwasser is there something obvious that I'm missing here? It feels a little bad that the triple slash gets included in our d.ts even though consumers might not want this typing. I found this open issue: microsoft/TypeScript#33111 |
Package Version: _______
Describe the bug
Adding
@azure/ms-rest-package
automatically adds@types/node
type definitions. We are working on a React/Typescript project which targets es5 and addingms-rest-js
reference internally pulls in @types/node which pulls in library definitions for es2018Due to this typescript compiler does not fail the build if newer ES features are used while targeting older ES runtimes.
Screenshots
Enabling "explainFiles" in typescript configs shows @types/node is added by 'node_modules/@azure/ms-rest-js/es/lib/webResource.d.ts' file.
To Reproduce
./node_modules/.bin/tsc -p tsconfig.json
in the shell.@types/node
types is added bynode_modules/@azure/ms-rest-js/es/lib/webResource.d.ts
file (shown by explain files tsc compiler option)Expected behavior
@azure/ms-rest-js
should not pollute lib definitions of consuming applications.The text was updated successfully, but these errors were encountered: