Skip to content

Migrate core/tooltip.js to goog.module syntax#5222

Merged
gonfunko merged 8 commits into
RaspberryPiFoundation:goog_modulefrom
gonfunko:tooltip
Sep 9, 2021
Merged

Migrate core/tooltip.js to goog.module syntax#5222
gonfunko merged 8 commits into
RaspberryPiFoundation:goog_modulefrom
gonfunko:tooltip

Conversation

@gonfunko

Copy link
Copy Markdown
Contributor

The basics

  • I branched from goog_module
  • My pull request is against goog_module
  • My code follows the style guide
  • My code is presented in the form suggested in the module
    conversion guide
  • I have run npm test.

The details

Resolves

Part of #5026

Proposed Changes

Converts core/tooltip.js to goog.module with ES6 const/let.

@gonfunko gonfunko requested a review from a team as a code owner July 26, 2021 19:50
@gonfunko gonfunko requested a review from cpcallen July 26, 2021 19:50
@github-actions github-actions Bot added this to the 2021_q3_release milestone Jul 26, 2021

@cpcallen cpcallen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally fine, but I have a few questions.

Comment thread core/tooltip.js
Comment on lines +54 to +75
const LIMIT = 50;
exports.LIMIT = LIMIT;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we expecting that developers will want to modify this value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked with Beka and she wasn't aware of and couldn't find anyone that was. I take the all-caps to imply that it was intended as a constant as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess the question then is: does it need to be exported? I don't see reference to it anywhere outside this file (but maybe it's referenced outside this repo?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's kind of annoying. First party plugins aren't supposed to monkey patch according to our own criteria. Sucks that this has to be made public because of that :/

Comment thread core/tooltip.js Outdated
Comment on lines +42 to +47
let visible = false;
exports.visible = visible;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't look correct. If we're exporting visible, presumably external code wants to know the current value of the flag, not just the initial value.

See the style guide under "Mutability of exports" for how to deal with this (but maybe for now exports.visible needs to be an actual getter, for backwards compatibility.)

(Also: perhaps add @type {boolean} to the JSDoc?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated this (and DIV) following the pattern we've settled on.

@cpcallen cpcallen removed their assignment Aug 4, 2021
@cpcallen

cpcallen commented Aug 4, 2021

Copy link
Copy Markdown
Collaborator

I'm un-assigning this from myself for now but feel free to reassign when you want a re-review.

@google-cla google-cla Bot added the cla: yes Used by Google's CLA checker. label Aug 12, 2021
@gonfunko gonfunko assigned cpcallen and unassigned gonfunko Aug 12, 2021

@cpcallen cpcallen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is fine, but I did have one niggle.

Comment thread core/tooltip.js
Comment on lines +54 to +75
const LIMIT = 50;
exports.LIMIT = LIMIT;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess the question then is: does it need to be exported? I don't see reference to it anywhere outside this file (but maybe it's referenced outside this repo?)

Comment thread core/tooltip.js Outdated
*/
let visible = false;
/** @deprecated September 2021 */
exports.visible = visible;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is being overwritten by a call to Object.defineProperties below, and somehow I dislike that, though I can't articulate exactly why.

It this the easiest way to get the correct documentation and type info associated with the exported name? I think I'd prefer a pure declaration, even though we'd be repeating the JSDoc:

/**
 * Is a tooltip currently showing?
 * @type {boolean}
 * @deprecated September 2021
 */
exports.visible;

Or even—since it's deprecated and a compiler warning might encourage people to migrate—just:

/** @deprecated September 2021 */
exports.visible;

("This is not important; wontfix" might be reasonable answer.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@cpcallen cpcallen assigned gonfunko and unassigned cpcallen Aug 13, 2021
@gonfunko gonfunko merged commit 646a931 into RaspberryPiFoundation:goog_module Sep 9, 2021
@gonfunko gonfunko deleted the tooltip branch September 9, 2021 19:45
cpcallen added a commit that referenced this pull request Sep 10, 2021
Running npm run build:deps in goog_module makes a change to tests/deps.js that was previously committed by PR #5441 but which appears to have been inadvertently undone by #5222.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Used by Google's CLA checker. type: cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants