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

chore: migrate src/Browser to TS #5761

Merged
merged 1 commit into from Apr 28, 2020
Merged

chore: migrate src/Browser to TS #5761

merged 1 commit into from Apr 28, 2020

Conversation

jackfranklin
Copy link
Collaborator

This was an interestng migration and hit upon some tweaks elsewhere in
the codebase where we can gain stricter typing now more code is ported
to TS.

This was an interestng migration and hit upon some tweaks elsewhere in
the codebase where we can gain stricter typing now more code is ported
to TS.
Copy link
Member

@mathiasbynens mathiasbynens left a comment

Choose a reason for hiding this comment

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

Rubberstamp LGTM

['midi', 'midi'],
['notifications', 'notifications'],
// TODO: push isn't a valid type?
// ['push', 'push'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mathiasbynens this is interesting to me. The protocol doesn't list push as a valid permission type so I'm not quite sure if:

  • the protocol is wrong
  • Puppeteer is wrong and calling overridePermissions with push was effectively a no-op.

I think I'm lacking context here so I can't really make a call. We can keep the code and loosen the types to string[] rather than PermissionType[] but if this is highlighting a bug it's worth exploring.

Copy link
Member

Choose a reason for hiding this comment

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

I lack the context here as well. Let's stick with the existing behavior for now, and we can resolve this separately later. Thanks for adding the TODO.

@@ -72,7 +72,7 @@ export class Connection extends EventEmitter {
return this._url;
}

send<ReturnType extends {}>(method: string, params = {}): Promise<ReturnType> {
send<T extends keyof Protocol.CommandParameters>(method: T, params?: Protocol.CommandParameters[T]): Promise<Protocol.CommandReturnValues[T]> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is an improvement on the types that I missed previously that was highlighted when migrating src/Browser

Copy link
Member

Choose a reason for hiding this comment

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

neat!

@@ -19,7 +19,7 @@
* to make this into TaskQueue<T> and let the caller tell us what types
* the promise in the queue should return.
*/
class TaskQueue {
export class TaskQueue {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this change allows the file to be imported into other TS files nicely

@mathiasbynens mathiasbynens merged commit 06d62c0 into master Apr 28, 2020
@mathiasbynens mathiasbynens deleted the migrate-browser-ts branch April 28, 2020 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants