Skip to content

Fix node url and http/https request types#18766

Merged
6 commits merged intoDefinitelyTyped:masterfrom
jeffkenney:fix-node-url-types
Oct 17, 2017
Merged

Fix node url and http/https request types#18766
6 commits merged intoDefinitelyTyped:masterfrom
jeffkenney:fix-node-url-types

Conversation

@jeffkenney
Copy link
Copy Markdown
Contributor

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

@dt-bot
Copy link
Copy Markdown
Member

dt-bot commented Aug 8, 2017

types/node/v6/index.d.ts

to authors (@DefinitelyTyped/DefinitelyTyped @WilcoBakker Microsoft TypeScript (account can't be detected)). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

Comment thread types/node/v6/index.d.ts
export interface Server extends tls.Server { }
export function createServer(options: ServerOptions, requestListener?: Function): Server;
export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
export function request(options: RequestOptions | string, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is not this change made to other versions of node, i.e. v7, and v8?

@DanielRosenwasser
Copy link
Copy Markdown
Member

Hey @jeffkenney could you apply the change to the other versions as well?

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Aug 18, 2017
@typescript-bot
Copy link
Copy Markdown
Contributor

This PR has been open and unchanged 5 days without signoff or complaint. This will be merged by a maintainer soon if there are no objections.

@jeffkenney
Copy link
Copy Markdown
Contributor Author

@mhegazy @DanielRosenwasser I'll work on getting the other versions updated.

@bowdenk7 bowdenk7 added the Revision needed This PR needs code changes before it can be merged. label Aug 22, 2017
@bowdenk7
Copy link
Copy Markdown

Will merge in once the other version is updated. Thanks!

@jeffkenney
Copy link
Copy Markdown
Contributor Author

jeffkenney commented Aug 24, 2017

Updates applied to all versions, also backported the split Url / UrlObject types to v0 and v4. The CI failures look unrelated.

@typescript-bot typescript-bot added The Travis CI build failed and removed Unmerged The author did not merge the PR when it was ready. labels Aug 30, 2017
@typescript-bot
Copy link
Copy Markdown
Contributor

@jeffkenney Please fix the failures indicated in the Travis CI log.

@typescript-bot typescript-bot added Abandoned This PR had no activity for a long time, and is considered abandoned The Travis CI build failed Revision needed This PR needs code changes before it can be merged. and removed The Travis CI build failed Revision needed This PR needs code changes before it can be merged. Abandoned This PR had no activity for a long time, and is considered abandoned labels Aug 31, 2017
@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Sep 7, 2017
@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Sep 14, 2017
@ghost
Copy link
Copy Markdown

ghost commented Oct 16, 2017

Hi @jeffkenney, could you fix the merge conflict? Then I'll take a quick look at the CI and hopefully merge. Thanks!

@ghost ghost merged commit 43a2660 into DefinitelyTyped:master Oct 17, 2017
Comment thread types/node/index.d.ts
export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
export function format(URL: URL, options?: URLFormatOptions): string;
export function format(urlObject: UrlObject): string;
export function format(urlObject: UrlObject | string): string;
Copy link
Copy Markdown
Contributor

@OliverJAsh OliverJAsh Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't format use the same type as parse returns? If so, how come we need both UrlObject and Url? Won't the latter suffice?

Also, I would suggest renaming Url to ParsedURL to disambiguate it from URL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From node docu: The value of urlObject.port is coerced to a string and appended to result
So in fact everything convertible to string is accepted here (which would be any) but you will get a string | null from parse().
In real world apps string | number is usually what is needed which is most likely the reason why noone complained yet.
There are several such places in node; e.a. you can set everything convertible to string as a http header.

KSXGitHub pushed a commit to KSXGitHub/DefinitelyTyped that referenced this pull request May 12, 2018
* [node] url.format can take a string

* [node] http.request / https.request can take a string

* [node] reorder Url properties to match ordering in docs

* [node] DRY out the Url and UrlObject types

* [node] backport split Url / UrlObject types to v0 and v4

* remove 'any' union for UrlObject.query type
@jeffkenney jeffkenney deleted the fix-node-url-types branch December 14, 2018 05:57
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants