-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
refactor: convert controlUtils to TypeScript (1 of 2) #13401
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typing looks reasonable, i'm assuming the rest was copy pasted
|
||
export const getControlConfig = function getControlConfig( | ||
controlKey: string, | ||
vizType: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we not have a type for vizType
yet? Seems like it should exist...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it doesn't. I've thought about creating a VizType
and actually did create a temporary type in an earlier iteration:
// TODO: replace this with string literals of actual supported viz types
type VizType = string;
But decided against it because it may not work well with dynamic plugins where viz types could be anything. If we do still find value in restricting viz types, we can do that while we convert MainPreset.js
to TS.
|
||
// apply section overrides | ||
Object.entries(sectionOverrides).forEach(([section, overrides]) => { | ||
if (typeof overrides === 'object' && overrides.constructor === Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need these safeguards still now that there's typing here? or is there a better way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all controlPanel
configs are TypeScript so I'd rather keep the same logic. We can do the cleanups after all plugins are migrated to TypeScript.
Codecov Report
@@ Coverage Diff @@
## master #13401 +/- ##
==========================================
- Coverage 77.44% 73.50% -3.94%
==========================================
Files 903 604 -299
Lines 45662 21241 -24421
Branches 5506 5430 -76
==========================================
- Hits 35361 15614 -19747
+ Misses 10175 5502 -4673
+ Partials 126 125 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
SUMMARY
Convert
getControlConfig
andgetSectionsToRender
(renamed fromsectionToRender
) to TypeScript.Will convert the remaining functions in
src/explore/controlUtils
in another PR.Part of the larger effort of adding typing to the control panel.
Related: #13221 #13374
This PR is based on #13374 , will rebase to
master
once it is merged.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No functional change
TEST PLAN
ADDITIONAL INFORMATION