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(tsc): add type checking to many core gatherers #4975

Merged
merged 2 commits into from
Apr 17, 2018
Merged

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented Apr 17, 2018

Turned on type checking for the top-level gatherers/, but then // @ts-nochecked three of the more involved ones :)

Everything here should be a non-functional change. Promise -> aync/await stuff is easier to view in ?w=1.

The only functional change was to mixed-content.js, which had a few issues (promise passed to promise.then(), event handler not actually removed), and it's not really observable except for fixed bugs and to the unit test which was reaching inside.

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.

nice! though could probably break it up into slightly smaller chunks :)

}
/**
* @param {string} pageUrl
* @param {Driver} driver
Copy link
Collaborator

Choose a reason for hiding this comment

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

return type is inferred? sweet!

if (this._onRequestIntercepted) {
driver.off('Network.requestIntercepted', this._onRequestIntercepted);
}
await driver.sendCommand('Network.setCacheDisabled', {cacheDisabled: false});
Copy link
Collaborator

Choose a reason for hiding this comment

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

heh, do we think this had any real impact on results so far then? probably didn't matter I suppose since the page was already loaded

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, technically it was running, just messing up the promise chain :) In theory some kind of racy thing could happen (or if there was an error, you'd end up with an unhandled promise rejection), but since we don't run this in smoke testing we'll never know! :)

function parseThemeColor(jsonInput) {
return parseColor(jsonInput.theme_color);
}

/**
* @param {*} jsonInput
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we be adding todos around any/* to type them later? speaking of which are we standardizing on any or * I'd have a slight preference for any thinking about it now just from a searching perspective

Copy link
Member Author

@brendankenny brendankenny Apr 17, 2018

Choose a reason for hiding this comment

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

should we be adding todos around any/* to type them later

I think for most cases, yes. There's usually no reason not to type stuff, so I think it would be good to go back and hit all our marks.

In this particular case, though, I'm not sure what the best thing is to do. We know what type we expect on each property, but the point of this file is taking some json to parse it and flag anything we don't expect :) Technically the type should be anything serializable by JSON, so we could narrow that, at least...

@brendankenny
Copy link
Member Author

nice! though could probably break it up into slightly smaller chunks :)

yeah, sorry, I'll keep things smaller in the future

@brendankenny brendankenny merged commit 3ce82a1 into master Apr 17, 2018
@brendankenny brendankenny deleted the tsgatherers branch April 17, 2018 22:37
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.

None yet

4 participants