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

[chai] add support for Set and Map to assert.lengthOf #66744

Merged
merged 2 commits into from Oct 10, 2023

Conversation

na-trium-144
Copy link
Contributor

@na-trium-144 na-trium-144 commented Sep 19, 2023

Documentation of chai says that I can check the size property of objects such as Set or Map with assert.lengthOf, but TypeScript gives error: Type 'Map<string, number>' has no properties in common with type '{ readonly length?: number | undefined; }'.
This PR fixes this error.

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.
  • Follow the advice from the readme.
  • Avoid common mistakes.
    • The common mistakes section in readme suggests to run prettier, but I didn't because it produced diffs where I did not changed.
  • Run npm test <package to test>.

Select one of these and delete the others:

If changing an existing definition:

@typescript-bot
Copy link
Contributor

typescript-bot commented Sep 19, 2023

@na-trium-144 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 66744,
  "author": "na-trium-144",
  "headCommitOid": "3f3b729d675692dae60c4eb6b723a022b32bf757",
  "mergeBaseOid": "6602670baf21cae33938757102eedc4ff6dbb3dc",
  "lastPushDate": "2023-09-19T07:34:58.000Z",
  "lastActivityDate": "2023-10-10T00:28:30.000Z",
  "maintainerBlessed": "Waiting for Code Reviews",
  "mergeOfferDate": "2023-10-09T16:43:05.000Z",
  "mergeRequestDate": "2023-10-10T00:28:30.000Z",
  "mergeRequestUser": "na-trium-144",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "chai",
      "kind": "edit",
      "files": [
        {
          "path": "types/chai/chai-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/chai/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "Bartvds",
        "AGBrown",
        "olivr70",
        "mwistrand",
        "shaunluttin",
        "micksatana",
        "ErikSchierboom",
        "bparan",
        "CXuesong",
        "joeykilpatrick"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "jakebailey",
      "date": "2023-10-09T16:42:20.000Z",
      "isMaintainer": true
    }
  ],
  "mainBotCommentID": 1724980718,
  "ciResult": "pass"
}

@typescript-bot
Copy link
Contributor

🔔 @Bartvds @AGBrown @olivr70 @mwistrand @shaunluttin @micksatana @ErikSchierboom @bparan @CXuesong @joeykilpatrick — 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.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Sep 19, 2023
@sheetalkamat sheetalkamat moved this from Needs Maintainer Review to Waiting for Code Reviews in New Pull Request Status Board Sep 19, 2023
@typescript-bot typescript-bot added the Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. label Sep 30, 2023
@typescript-bot
Copy link
Contributor

Re-ping @Bartvds, @AGBrown, @olivr70, @mwistrand, @shaunluttin, @micksatana, @ErikSchierboom, @bparan, @CXuesong, @joeykilpatrick:

This PR has been out for over a week, yet I haven't seen any reviews.

Could someone please give it some attention? Thanks!

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in New Pull Request Status Board Oct 7, 2023
@typescript-bot
Copy link
Contributor

It has been more than two weeks and this PR still has no reviews.

I'll bump it to the DT maintainer queue. Thank you for your patience, @na-trium-144.

(Ping @Bartvds, @AGBrown, @olivr70, @mwistrand, @shaunluttin, @micksatana, @ErikSchierboom, @bparan, @CXuesong, @joeykilpatrick.)

@@ -1210,7 +1210,11 @@ declare namespace Chai {
* @param length Potential expected length of object.
* @param message Message to display on error.
*/
lengthOf<T extends { readonly length?: number | undefined }>(object: T, length: number, message?: string): void;
lengthOf<T extends { readonly length?: number | undefined } | { readonly size?: number | undefined }>(
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a new problem, but I don't understand why this is a generic at all. It could just accept this constraint as the parameter type.

That and, this type technically accepts the literal {} as an argument, which feels wrong.

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner and removed Unreviewed No one showed up to review this PR, so it'll be reviewed by a DT maintainer. labels Oct 9, 2023
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Author to Merge in New Pull Request Status Board Oct 9, 2023
@typescript-bot
Copy link
Contributor

@na-trium-144: Everything looks good here. I am ready to merge this PR (at 3f3b729) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@Bartvds, @AGBrown, @olivr70, @mwistrand, @shaunluttin, @micksatana, @ErikSchierboom, @bparan, @CXuesong, @joeykilpatrick: you can do this too.)

@na-trium-144
Copy link
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Oct 10, 2023
@typescript-bot typescript-bot merged commit 1c08a49 into DefinitelyTyped:master Oct 10, 2023
2 checks passed
@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants