Skip to content
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/koa-session: support missing options #32507

Merged

Conversation

hirochachacha
Copy link
Contributor

@hirochachacha hirochachacha commented Jan 26, 2019

Please fill in this template.

  • 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.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • 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:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/koajs/session/blob/23ad8718a9a392c0c563893a10b5ca9f6fd70ebe/lib/context.js#L130
    interface GetOption {
    signed: boolean;
    }
    interface SetOption {
    /**
    * a number representing the milliseconds from Date.now() for expiry
    */
    maxAge?: number;
    /**
    * a Date object indicating the cookie's expiration
    * date (expires at the end of session by default).
    */
    expires?: Date;
    /**
    * a string indicating the path of the cookie (/ by default).
    */
    path?: string;
    /**
    * a string indicating the domain of the cookie (no default).
    */
    domain?: string;
    /**
    * a boolean indicating whether the cookie is only to be sent
    * over HTTPS (false by default for HTTP, true by default for HTTPS).
    */
    secure?: boolean;
    /**
    * "secureProxy" option is deprecated; use "secure" option, provide "secure" to constructor if needed
    */
    secureProxy?: boolean;
    /**
    * a boolean indicating whether the cookie is only to be sent over HTTP(S),
    * and not made available to client JavaScript (true by default).
    */
    httpOnly?: boolean;
    /**
    * a boolean or string indicating whether the cookie is a "same site" cookie (false by default).
    * This can be set to 'strict', 'lax', or true (which maps to 'strict').
    */
    sameSite?: 'strict' | 'lax' | boolean;
    /**
    * a boolean indicating whether the cookie is to be signed (false by default).
    * If this is true, another cookie of the same name with the .sig suffix
    * appended will also be sent, with a 27-byte url-safe base64 SHA1 value
    * representing the hash of cookie-name=cookie-value against the first Keygrip key.
    * This signature key is used to detect tampering the next time a cookie is received.
    */
    signed?: boolean;
    /**
    * a boolean indicating whether to overwrite previously set
    * cookies of the same name (false by default). If this is true,
    * all cookies set during the same request with the same
    * name (regardless of path or domain) are filtered out of
    * the Set-Cookie header when setting this cookie.
    */
    overwrite?: boolean;
    }
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

@typescript-bot
Copy link
Contributor

typescript-bot commented Jan 26, 2019

@hirochachacha Thank you for submitting this PR!

🔔 @kerol2r20 @tlaziuk @DimaMukhin - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot moved this from Waiting for Reviewers to Review in Pull Request Status Board Jan 31, 2019
@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Jan 31, 2019
@typescript-bot
Copy link
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@@ -108,7 +112,7 @@ declare namespace session {
hash(sess: any): string;
}

interface opts {
interface opts extends Omit<Cookies.SetOption, 'maxAge'> {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can consider changing to Omit<T, K extends keyof T>. That way the string "maxAge" is now tied to the property maxAge on Cookies.SetOption (so if they change the name or remove it then this library will break too and you can make the appropriate changes here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Thank you. Honestly, I hope Typescript team will reconsider microsoft/TypeScript#12215 since there are about 90 files that use Omit type in this repo.

$ ag -l Omit | wc -l
      94

@PranavSenthilnathan PranavSenthilnathan merged commit c314e5a into DefinitelyTyped:master Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unmerged The author did not merge the PR when it was ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants