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 explicit index signature in mainthread-work-breakdown #5859

Merged
merged 1 commit into from
Aug 20, 2018

Conversation

brendankenny
Copy link
Member

Another change anticipating typescript 3.1nightly. Default index signatures are going away in JS (my fault :), so we'll need to migrate anything relying on that to either fully defined objects or explicit index signatures. We use those in a lot of places, so I thought I'd start now :)

Here TaskGroupIds just becomes the object's signature.

@@ -5,9 +5,11 @@
*/
'use strict';

/** @typedef {'parseHTML'|'styleLayout'|'paintCompositeRender'|'scriptParseCompile'|'scriptEvaluation'|'garbageCollection'|'other'} TaskGroupIds */
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've been wondering is there not a way to get these programmtically via some keyof magic?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know we're going the opposite direction by declaring the type of the object as matching this, but ya know just for knowledge :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been wondering is there not a way to get these programmtically via some keyof magic?

I tried really hard :) but I couldn't find a way to get out of the circularity of needing TaskGroup.id to be able to index taskGroups in mainthread-work-breakdown.js, which means the taskGroups declaration needs to be typed, not just inferred (it would go to string), which means you can't meaningfully do keyof on it

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, you could do one really terrible thing...

const taskGroups = {
  parseHTML: {
    id: /** @type {'parseHTML'} */ ('parseHTML'),
    // ...
  },
  styleLayout: {
    id: /** @type {'styleLayout'} */ ('styleLayout'),
    // ...
  }, // ...
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

alright thanks good to know!

@brendankenny
Copy link
Member Author

@patrickhulce are you 👍 for this then?

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.

LGTM!

@brendankenny brendankenny merged commit 0203330 into master Aug 20, 2018
@brendankenny brendankenny deleted the mainthreadindex branch August 20, 2018 18:53
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

2 participants