Skip to content

Complete mapping as of tough-cookie 2.3.2 - #4

Merged
blakeembrey merged 11 commits into
typed-typings:masterfrom
brainbeanapps:master
Mar 23, 2017
Merged

blakeembrey merged 11 commits into
typed-typings:masterfrom
brainbeanapps:master

Conversation

@alexey-pelykh

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread lib/cookie.d.ts Outdated
* If no cookie is found then null MUST be passed instead (i.e. not an error).
*/
httpOnly?: boolean;
findCookie(domain: string, path: string, key: string, cb: (error: Error, cookie: Cookie) => any): any;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nitpick: Can you add a space after the method names to stay consistent with the rest of the file?

Also, should the return type here be void?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's closer to void than any, I'd still write this as the callback being => void and the return of the entire function being void too. And I tend to always write my callbacks in that style too, just a weird preference thing for returning when I definitely don't want anything occurring after an async action to indicate intent. If you really want to keep it accurate, would you like to make it a generic instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should any be void'ed also in places like

  setCookie (cookieOrString: string | Cookie, currentUrl: string, cb: (err: Error, cookie?: Cookie) => any): void;

(original code)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I think so. I used to write any over void because I had run into some random issues in the past, but the correct type should have been void from the beginning. Feel free to submit another PR to correct that, in the callback positions I haven't really cared since whatever the user puts is good, but it should still prefer void I believe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated yet keeping consistent with original code

Comment thread lib/cookie.d.ts
* // yuck!
* }
* </code></pre>
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't recall if it's used anywhere else in the file, but would you mind using markdown-style triple backticks over HTML? I'm not sure either are currently used anywhere though.

@blakeembrey

Copy link
Copy Markdown
Member

Looks great! 👍 I just have a couple of minor comments and then I'll merge. Also, if you want to update https://github.com/types/npm-tough-cookie/blob/05f8c59af4823af51f3ea54927c43253696bc71f/typings.json#L3 it might be helpful too (just to 2.3 or whichever version this is specific for).

@alexey-pelykh

Copy link
Copy Markdown
Contributor Author

@blakeembrey replaced the HTML with markdown. Haven't noticed that those were used already :)

@blakeembrey
blakeembrey merged commit b058598 into typed-typings:master Mar 23, 2017
@blakeembrey

Copy link
Copy Markdown
Member

Thanks again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants