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

core: add type checking to connection #4738

Merged
merged 3 commits into from
Mar 12, 2018
Merged

core: add type checking to connection #4738

merged 3 commits into from
Mar 12, 2018

Conversation

brendankenny
Copy link
Member

no significant changes, mostly typings (e.g. runJsonCommand returns an object, not a string).

The biggest shifts were just e.g. assuring the compiler we wouldn't emit events after the event emitter was disposed.

For the future, there are a lot of opportunities for better typing on these methods that take a string but return a bunch of different things via TS's conditional types (or plain overloading with string literal arguments)

@@ -28,7 +28,7 @@ class ReportScoring {
/**
* Returns the report JSON object with computed scores.
* @param {{categories: !Object<string, {id: string|undefined, weight: number|undefined, audits: !Array<{id: string, weight: number|undefined}>}>}} config
* @param {!Object<{score: ?number|boolean|undefined}>} resultsByAuditId
* @param {!Object<string, {score: ?number|boolean|undefined, notApplicable: boolean, informative: boolean}>} resultsByAuditId
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure why this wasn't failing before. Possibly from the update to ts 2.7.2?

// first, we activate it to a foreground tab, then we connect
return this._runJsonCommand(`activate/${firstTab.id}`)
.then(_ => this._connectToSocket(firstTab));
.then(() => this._connectToSocket(firstTab));
Copy link
Collaborator

Choose a reason for hiding this comment

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

😄

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

yay for more ts! :D

@paulirish paulirish merged commit e675e1b into master Mar 12, 2018
@paulirish paulirish deleted the tsconn branch March 12, 2018 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants