Migrate core/tooltip.js to goog.module syntax#5222
Conversation
cpcallen
left a comment
There was a problem hiding this comment.
Generally fine, but I have a few questions.
| const LIMIT = 50; | ||
| exports.LIMIT = LIMIT; |
There was a problem hiding this comment.
Are we expecting that developers will want to modify this value?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Looks like it's used in blockly-samples: https://github.com/google/blockly-samples/blob/1be2b748414ef147c8f7d657fa440442c0ef49a8/plugins/block-extension-tooltip/src/tooltip_monkey_patch.ts
There was a problem hiding this comment.
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 :/
| let visible = false; | ||
| exports.visible = visible; |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Updated this (and DIV) following the pattern we've settled on.
|
I'm un-assigning this from myself for now but feel free to reassign when you want a re-review. |
cpcallen
left a comment
There was a problem hiding this comment.
I think this is fine, but I did have one niggle.
| const LIMIT = 50; | ||
| exports.LIMIT = LIMIT; |
There was a problem hiding this comment.
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?)
| */ | ||
| let visible = false; | ||
| /** @deprecated September 2021 */ | ||
| exports.visible = visible; |
There was a problem hiding this comment.
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.)
The basics
goog_modulegoog_moduleconversion guide
npm test.The details
Resolves
Part of #5026
Proposed Changes
Converts
core/tooltip.jstogoog.modulewith ES6const/let.