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

update(yargs): Types for arg in MiddlewareFunction #52265

Closed
wants to merge 2 commits into from

Conversation

seivan
Copy link

@seivan seivan commented Apr 8, 2021

Middlewares in commands do not passed typed arguments.
This will make sure that whatever types passed to handler also gets into MiddlewareFunction

Better types would have handler get a combination of types from returned values of MiddlewareFunction and builder
So a middleware can modify content of args before being passed to handler, some other time I guess.

The CI is failing with

ERROR: 152:27  array-type  Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.
92
ERROR: 160:27  array-type  Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.
93
ERROR: 169:27  array-type  Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.
94

But I haven't introduced T[] they were already there, is it ok if I change them to Array<T>?
I avoided changing existing conventions.

Select one of these and delete the others:

If changing an existing definition:

@typescript-bot typescript-bot added Critical package Untested Change This PR does not touch tests labels Apr 8, 2021
@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 8, 2021

Hey @seivan,

😒 Your PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Please consider adding tests to cover the change you're making. Including tests allows this PR to be merged by yourself and the owners of this module.

This can potentially save days of time for you!

@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Apr 8, 2021
@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 8, 2021

@seivan 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 this is a widely-used package, a DT maintainer will need to review it before it can be merged.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Only a DT maintainer can approve changes without tests

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.

Inactive

This PR has been inactive for 31 days — closed because it wasn't merged for a long time!


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 52265,
  "author": "seivan",
  "headCommitOid": "e563588e680f5658812b2cc39a2c2c2be2dc0509",
  "lastPushDate": "2021-04-08T15:37:00.000Z",
  "lastActivityDate": "2021-04-14T18:04:18.000Z",
  "mergeOfferDate": "2021-04-14T18:04:58.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "yargs",
      "kind": "edit",
      "files": [
        {
          "path": "types/yargs/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "poelstra",
        "mizunashi-mana",
        "pushplay",
        "JimiC",
        "steffenvv",
        "forivall",
        "ExE-Boss",
        "Aankhen"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "rbuckton",
      "date": "2021-04-14T18:04:18.000Z",
      "isMaintainer": true
    }
  ],
  "ciResult": "pass"
}

@typescript-bot
Copy link
Contributor

🔔 @poelstra @mizunashi-mana @pushplay @JimiC @steffenvv @forivall @ExE-Boss @Aankhen — 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 Apr 8, 2021
@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Apr 8, 2021
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Needs Author Action in New Pull Request Status Board Apr 8, 2021
@typescript-bot
Copy link
Contributor

@seivan The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Instead of existing `T[]`. New conventions?
@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Apr 8, 2021
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Apr 8, 2021
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Apr 8, 2021
@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #52265 diff
Batch compilation
Memory usage (MiB) 87.7 87.9 +0.2%
Type count 16984 17008 0%
Assignability cache size 3010 3011 0%
Language service
Samples taken 1578 1578 0%
Identifiers in tests 1578 1578 0%
getCompletionsAtPosition
    Mean duration (ms) 374.3 369.1 -1.4%
    Mean CV 9.5% 9.1%
    Worst duration (ms) 721.3 750.5 +4.1%
    Worst identifier yargs array
getQuickInfoAtPosition
    Mean duration (ms) 371.4 366.1 -1.4%
    Mean CV 9.3% 8.8%
    Worst duration (ms) 698.3 686.3 -1.7%
    Worst identifier positional argv2

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Apr 8, 2021
@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Apr 14, 2021
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Author to Merge in New Pull Request Status Board Apr 14, 2021
@typescript-bot
Copy link
Contributor

@seivan Everything looks good here. Great job! I am ready to merge this PR (at e563588) on your behalf.

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! ❤️

(@poelstra, @mizunashi-mana, @pushplay, @JimiC, @steffenvv, @forivall, @ExE-Boss, @Aankhen: you can do this too.)

@@ -835,7 +835,7 @@ declare namespace yargs {
type SyncCompletionFunction = (current: string, argv: any) => string[];
type AsyncCompletionFunction = (current: string, argv: any, done: (completion: ReadonlyArray<string>) => void) => void;
type PromiseCompletionFunction = (current: string, argv: any) => Promise<string[]>;
type MiddlewareFunction<T = {}> = (args: Arguments<T>) => void;
type MiddlewareFunction<U> = (args: Arguments<U>) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

this should still have a default type for U

@typescript-bot
Copy link
Contributor

Re-ping @seivan / @poelstra, @mizunashi-mana, @pushplay, @JimiC, @steffenvv, @forivall, @ExE-Boss, @Aankhen:

This PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on May 14th (in three weeks) if this doesn't happen.

(If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.)

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Apr 24, 2021
@typescript-bot typescript-bot removed this from Waiting for Author to Merge in New Pull Request Status Board May 15, 2021
@typescript-bot
Copy link
Contributor

After a month, no one has requested merging the PR 😞. I'm going to assume that the change is not wanted after all, and will therefore close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Maintainer Approved Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner Unmerged The author did not merge the PR when it was ready. Untested Change This PR does not touch tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants