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): update to latest tsc #5581

Merged
merged 3 commits into from
Aug 8, 2018
Merged

core(tsc): update to latest tsc #5581

merged 3 commits into from
Aug 8, 2018

Conversation

brendankenny
Copy link
Member

  • allows us to get rid of the includes ordering hack in tsconfig
  • allows expanding the deep @type types in a few places to the more standard (and readable) @param/@param/@return form
  • catches a (type) error in the default values of our protocol parameters (shouldn't be {} if we want them to default to void)
  • catches a (type) bug trying to pass an Array<string> where a string is expected (never actually happens at runtime)
  • allows @template with type constraints. In theory this allows us to bring back in all the Driver.on, etc methods that I moved out of class bodies to the end of the file, but for now I'm leaving in place (except for one) because typescript stopped inferring parameter types on things like
this.on('Page.javascriptDialogOpening', data => {
  // stuff with `data` which is known as type `LH.Crdp.Page.JavascriptDialogOpeningEvent`
}

I'll have to investigate why that's happening (probably microsoft/TypeScript#1449), but really nice to have that ability now.

@brendankenny
Copy link
Member Author

sorry spammers, I made a real PR out of the branch :P

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.

seems cool!

@@ -226,7 +226,13 @@ class LighthouseReportViewer {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = function(e) {
resolve(e.target && e.target.result);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why? is new ts stricter on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

technically it's somewhat more correct. They had a custom FileReaderLoadEvent passed to onload before, which always has the target set to the FileReader, but that isn't a real standardized event. They're moving to automatically generate the types from Edge's Web IDL files, so I think that's why that custom event was eliminated.

However, the event should be generic, parameterized on the element itself so that the type is known and it isn't just an EventTarget but the actual element, but they haven't done that. Sort of for performance reasons, but probably also partly because people aren't asking hard enough: microsoft/TypeScript-DOM-lib-generator#207

@@ -65,7 +65,9 @@ async function runLighthouseInExtension(options, categoryIDs) {
throw new Error('no runnerResult generated by Lighthouse');
}

const blobURL = createReportPageAsBlob(runnerResult);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does ts require us to do this now?

Copy link
Member Author

Choose a reason for hiding this comment

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

runnerResult.report is string | Array<string>, but we were treating it as a string (which it is in this case, but the compiler doesn't know that). I'm not sure why it wasn't catching it before.

@@ -11,6 +11,7 @@
/** @type {Record<LH.Locale, LocaleMessages>} */
const locales = {
'en-US': require('./en-US.json'), // The 'source' strings, with descriptions
// @ts-ignore - tsc bug, something about en/en-US pointing to same file
Copy link
Member Author

Choose a reason for hiding this comment

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

this is a really weird bug. Any characters changed or added to either the en or en-US keys makes the error go away

@brendankenny brendankenny merged commit 82ff1fe into master Aug 8, 2018
@brendankenny brendankenny deleted the updatetsc branch August 8, 2018 01:14
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.

3 participants