Skip to content

Conversation

@Hannes-Magnusson-CK
Copy link
Contributor

@Hannes-Magnusson-CK Hannes-Magnusson-CK commented Dec 1, 2017

  • 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
Member

dt-bot commented Dec 1, 2017

types/node/index.d.ts

to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis @OliverJAsh @eps1lon Microsoft TypeScript (account can't be detected)). Could you review this PR?
👍 or 👎?

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Dec 1, 2017
Copy link
Contributor

@Flarna Flarna left a comment

Choose a reason for hiding this comment

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

For completeness I would suggest to update also ConnectionOptions.checkServerIdentity to typeof checkServerIdentity.

// TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version.
/* tslint:disable:callable-types */
interface NodeRequireFunction {
/* tslint:disable-next-line:callable-types */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicate of #21768.

@Hannes-Magnusson-CK
Copy link
Contributor Author

Added CheckServerIdentityFunction as a type and used it in the ConnectionOptions.

Did not remove the lint fix as the linked PR hasn't been merged

@typescript-bot
Copy link
Contributor

@Hannes-Magnusson-CK Please fix the failures indicated in the Travis CI log.

@Hannes-Magnusson-CK
Copy link
Contributor Author

Travis is passing. I had a syntax error for a second that was fixed before that comment was added

path?: string;
ALPNProtocols?: Array<string | Buffer>;
checkServerIdentity?: (servername: string, cert: string | Buffer | Array<string | Buffer>) => any;
checkServerIdentity?: CheckServerIdentityFunction;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it possible to write checkServerIdentity?: typeof checkServerIdentity here and avoid the extra type CheckServerIdentityFunction?
This would ensure that the function and the property here are always in sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only use of typeof in this file was in the Global interface definition, so it seemed like it wasn't expected syntax to use, so I followed the lead of LookupFunction.

If you think using typeof directly and removing the type declaration is kosher in this file, then I'll fix :D

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason why I used a dedicated type for LookupFunction instead typeof dns.lookup is that dns.lookup offers more options that the variant used by sockets and I don't think there is a typeof operand to select just the type of one specific overload.
But here we don't have this special case therefore I would suggest to go for typeof - except someone else (or CI) explains why not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha. Fixed :)

@typescript-bot
Copy link
Contributor

Approved by a listed owner. PR ready to merge pending express review by a maintainer.

@aozgaa aozgaa merged commit 476a6fe into DefinitelyTyped:master Dec 5, 2017
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.

6 participants