Repository navigation
[node] Fix https? classes - #17720
blakeembrey wants to merge 1 commit into
Conversation
|
types/node/index.d.ts to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @robdesideri @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna Microsoft TypeScript (account can't be detected)). Could you review this PR? Checklist
types/node/v4/index.d.ts to authors (@DefinitelyTyped/DefinitelyTyped Microsoft TypeScript (account can't be detected)). Could you review this PR? Checklist
types/node/v6/index.d.ts to authors (@DefinitelyTyped/DefinitelyTyped @WilcoBakker Microsoft TypeScript (account can't be detected)). Could you review this PR? Checklist
types/node/v7/index.d.ts to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @robdesideri @tellnes @WilcoBakker Microsoft TypeScript (account can't be detected)). Could you review this PR? Checklist
|
|
Note: This did delete the deprecated and non-existing stuff in the |
| export function createClient(port?: number, host?: string): any; | ||
| export function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; | ||
| export function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; | ||
| export function request(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; |
There was a problem hiding this comment.
Why have you removed URL from interface? Even typescript accepts this currently I would prefer to add it to make clear that url.URL is supported here (see https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_http_request_options_callback).
There was a problem hiding this comment.
Because it's wrong? It just happens that URL is assignable to RequestOptions, so this still works fine.
There was a problem hiding this comment.
We can make sure there's a test case for this, but adding URL should be redundant (if the typings are correct).
There was a problem hiding this comment.
Currently it's redundant as it is enough that at least one property from URL matches RequestOptions. But URL would be also allowed if there would be no match as this is a separate path in code. Was added somewhere in NodeJS 7.x
| [header: string]: number | string | string[]; | ||
| } | ||
|
|
||
| export interface IncomingHeaders { |
There was a problem hiding this comment.
Why rename IncomingMessageHeaders to IncomingHeaders?
Please consider also to add | undefined or even split it up to two interfaces (one for string | undefined one for "set-cookie": string[]). See #17157 for details (in special last comments)
| import * as stream from "stream"; | ||
| import { URL } from "url"; | ||
|
|
||
| export interface OutgoingHeaders { |
There was a problem hiding this comment.
Why do you replace ServerResponseHeaders by OutgoingHeaders?
There was a problem hiding this comment.
Consistency, but I can change it back since there's no semver in DT.
There was a problem hiding this comment.
personally I don't care that much as I would get hit just at one or two places. but others may see more impact.
|
|
||
| export interface Server extends net.Server { | ||
| export class Server extends net.Server { | ||
| constructor(req: IncomingMessage, res: ServerResponse); |
There was a problem hiding this comment.
I think Server constructor gets a request listener (requestListener: (req: IncomingMessage, res: ServerResponse) => void) as optional parameter, not an IncomingMessage and ServerResponse object.
| write(str: string, encoding?: string, fd?: string): boolean; | ||
|
|
||
| addTrailers(headers: ServerResponseHeaders): void; | ||
| export class OutgoingMessage extends stream.Writable { |
There was a problem hiding this comment.
According to the documentation (https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_class_http_serverresponse) Outgoing message does not inherit from stream.Writeable but it is an EventEmitter
| cert?: any; | ||
| ca?: any; | ||
| cert?: string | Buffer; | ||
| ca?: string | Buffer | string[] | Buffer[]; |
There was a problem hiding this comment.
according to https://nodejs.org/dist/latest-v8.x/docs/api/tls.html#tls_tls_createsecurecontext_options cert and cashould be string | string[] | Buffer | Buffer[]
There was a problem hiding this comment.
That is what it says, matches what you just commented on 👍
There was a problem hiding this comment.
ca matches but cert does not. Seems I was interrupted too often during my review...
| /** | ||
| * Private key to use for SSL. Default `null`. | ||
| */ | ||
| key?: string | Buffer | string[] | Buffer[]; |
|
|
||
| export class Server extends tls.Server { } | ||
|
|
||
| export function createServer(options: ServerOptions, requestListener?: Function): Server; |
There was a problem hiding this comment.
Better typing of requestListener got lost.
| export class Server extends tls.Server { } | ||
|
|
||
| export function createServer(options: ServerOptions, requestListener?: Function): Server; | ||
| export function request(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; |
There was a problem hiding this comment.
Variant to use URL as option got lost.
| /** | ||
| * Returns the current number of concurrent connections on the server. | ||
| */ | ||
| connections: number; |
There was a problem hiding this comment.
I think connections can be removed here has it should be visible from net.Server
There was a problem hiding this comment.
True. It's really only here because of the docblock, but I can move that to net.
|
Nice work! Seems some dependent packages use the deprecated types you removed but it should be simple to adapt them. |
|
Thanks for the review @Flarna. I'll try to come back to these, but it'll take some time. |
|
@blakeembrey Please fix the failures indicated in the Travis CI log. |
|
Thanks for your review @Flarna. I think I'll just keep the changes in my own repo for now since I can't do the work myself and I don't want the bot heckling me. I might try to go the other way when I can - it'll probably be easier to pull all the changes into @types and if I get them back in sync with DT, then I'll reverse the PR. Of course, there's some deviations made in @types for consistency or deleting deprecated code that I'll consider when reversing it, but for now it's more than I can do myself. Thanks again for your thoughtful review ❤️ |
|
Our new best friends the bots... |
|
nice work! |

Changes the
httpinterfaces to correctly be classes. Some of it is directly copied from @types.I was hoping to be able to copy more across, especially from a few of the modules I typed from scratch in https://github.com/types/env-node (
fs,path,tls,crypto,child_processetc), but things have diverged too much for me to take the time to verify the conflicts. One day I might get to them. The initial work took me around 12 hours in @types, so copying it across for someone else might be a bit quicker in the future (plus there's the specific commits you can grab, e.g. typed-typings/env-node@f3dc512).