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

[chrome-remote-interface] add support for shorthand callback version of events #63570

Merged

Conversation

kazarmy
Copy link
Contributor

@kazarmy kazarmy commented Dec 11, 2022

Please fill in this template.

If changing an existing definition:

This pr adds support for statements of the form:

Network.requestWillBeSent((params) => {
    // ...
});

as shorthand for

client['Network.requestWillBeSent']((params) => {
    // ...
});

Unfortunately there doesn't seem to be a way to copy over associated JSDoc, but they can be retrieved easily (with slight inconvenience) using the second form above, e.g. by typing in

client['Network.requestWillBeSent']

and then hovering the mouse over the partial statement.

@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 11, 2022

@kazarmy Thank you for submitting this PR!

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, DT maintainers or others

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": 63570,
  "author": "kazarmy",
  "headCommitOid": "f35cec38aa064af255cf94b7475a10df8f946a1e",
  "mergeBaseOid": "b527ff5063897a5947d5fc0aa4ac5e549c8791a9",
  "lastPushDate": "2022-12-11T08:40:06.000Z",
  "lastActivityDate": "2022-12-11T14:38:45.000Z",
  "mergeOfferDate": "2022-12-11T14:37:51.000Z",
  "mergeRequestDate": "2022-12-11T14:38:45.000Z",
  "mergeRequestUser": "kazarmy",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "chrome-remote-interface",
      "kind": "edit",
      "files": [
        {
          "path": "types/chrome-remote-interface/chrome-remote-interface-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/chrome-remote-interface/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "kazarmy",
        "westy92"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "westy92",
      "date": "2022-12-11T14:37:07.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 1345460484,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added the Author is Owner The author of this PR is a listed owner of the package. label Dec 11, 2022
@typescript-bot
Copy link
Contributor

🔔 @westy92 — 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 added this to Waiting for Code Reviews in New Pull Request Status Board Dec 11, 2022
Copy link
Contributor

@westy92 westy92 left a comment

Choose a reason for hiding this comment

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

Very impressive! 🎉
The missing JSDocs are fine, at least for now.
Could @borrows (https://jsdoc.app/tags-borrows.html) be helpful here?

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Dec 11, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Dec 11, 2022
@typescript-bot typescript-bot removed Self Merge This PR can now be self-merged by the PR author or an owner Owner Approved A listed owner of this package signed off on the pull request. labels Dec 11, 2022
@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Waiting for Code Reviews in New Pull Request Status Board Dec 11, 2022
@typescript-bot
Copy link
Contributor

@westy92 Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@kazarmy
Copy link
Contributor Author

kazarmy commented Dec 11, 2022

Sorry @westy92, could you reapprove? The most recent commit (f35cec3) is just to make sure that the callback parameter list for:

Page.frameResized(() => {

is the same as for:

client['Page.frameResized'](() => {

@kazarmy
Copy link
Contributor Author

kazarmy commented Dec 11, 2022

Could @borrows (https://jsdoc.app/tags-borrows.html) be helpful here?

The problem is that I can't do:

        /**
         * @borrows `${D}.${E}` as `${E}`
         */
        [event in GetEvent<D>]:

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Dec 11, 2022
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Dec 11, 2022
@kazarmy
Copy link
Contributor Author

kazarmy commented Dec 11, 2022

Thanks! 🎉

@kazarmy
Copy link
Contributor Author

kazarmy commented Dec 11, 2022

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Dec 11, 2022
@typescript-bot typescript-bot merged commit 6f97745 into DefinitelyTyped:master Dec 11, 2022
@kazarmy
Copy link
Contributor Author

kazarmy commented Dec 11, 2022

Regarding the JSDoc problem, another option is to use key remapping, say:

type DoEventProps<D extends string> = {
    [event in keyof ProtocolMappingApi.Events as GetEventFromString<D, event>]:
        (listener: (params: GetReturnType<D, GetEventFromString<D, event>>, sessionId?: string) => void) => () => Client};

but microsoft/TypeScript#50715 indicates that JSDoc documentation isn't currently transferred over, so I suppose the JSDoc problem will have to be put on hold for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author is Owner The author of this PR is a listed owner of the package. Owner Approved A listed owner of this package signed off on the pull request. 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