refactor: Switch to generated jsapi types#1842
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1842 +/- ##
=======================================
Coverage 46.07% 46.08%
=======================================
Files 635 635
Lines 37978 38013 +35
Branches 9586 9608 +22
=======================================
+ Hits 17499 17517 +18
- Misses 20425 20443 +18
+ Partials 54 53 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
mofojed
left a comment
There was a problem hiding this comment.
Not done yet but posting some minor feedback so far. Couple of things to change.
Still need to review the rest.
| const newAuthConfigValues = (await client.getAuthConfigValues()) as [ | ||
| string, | ||
| string, | ||
| ][]; |
There was a problem hiding this comment.
This kind of sucks, but I don't have any clever solutions. Would need a type predicate to map the string[][] to [string, string][] by checking each element I guess? isMapConstructorArray or something.
I also assume that GWT can't express this typing, otherwise that would be the best option to fix it in the jsapi-types source (though can have this temporarily).
There was a problem hiding this comment.
I did note this in a non-critical improvements ticket deephaven/deephaven-core#5082
Ya we could add a util to actually check it since this is just assuming it's an array of string pairs
| xaxis: this.makeLayoutAxis(dh.plot.AxisType.X, theme), | ||
| yaxis: this.makeLayoutAxis(dh.plot.AxisType.Y, theme), | ||
| zaxis: this.makeLayoutAxis(dh.plot.AxisType.Z, theme), | ||
| zaxis: this.makeLayoutAxis(null, theme), |
There was a problem hiding this comment.
Ah, on Enterprise it did used to have this constant. I guess we still need to set this for theming purposes of 3d plots in plotly-express? Wondering if we can just remove it and makeLayoutAxis doesn't need to take null then.
There was a problem hiding this comment.
We use just the X or Y in makeLayoutAxis to add a few params to X or Y axis specifically
That said, w/ the theme changes I think that could be removed entirely and in the defaults here we could instead do something like this for the 1-2 props we add to the X and Y axis. I'd say do that as a followup though to keep this PR just related to types
xaxix: {
...this.makeLayoutAxis(theme),
showgrid: true
}| column, | ||
| advancedFilterOptions, | ||
| sortDirection, | ||
| sortDirection as SortDirection, |
There was a problem hiding this comment.
Guessing GWT can't express Literal types for sort either... rather than casting should we have a method to convert it and throw if it can't be converted? Would be more "correct".
Side note, not sure how this isn't an error currently, since null shouldn't match SortDirection | undefined
There was a problem hiding this comment.
Ya I think there were some issues with it/not a high priority. I'll add a typeguard and check for this.
SortDirection is `"ASC" | "DESC" | "REVERSE" | null``, so that's why it doesn't fail
| if (name == null) { | ||
| throw new Error('Column header group has no name'); | ||
| } |
There was a problem hiding this comment.
Can make this kind of check a one-liner:
| if (name == null) { | |
| throw new Error('Column header group has no name'); | |
| } | |
| assertNotNull(name, 'Column header group has no name'); |
Possibly we should be verifying the group name isn't an empty string either, but that doesn't need to be this PR.
| } | ||
|
|
||
| listenerCleanup: RemoverFn | null; | ||
| listenerCleanup: (() => void) | null; |
There was a problem hiding this comment.
Thought for future - this pattern of a cleanup function is common enough, we should have a utility type defined for () => void. Referencing ReturnType<DhType.HasEventHandling['addEventListener']> is possible too but gross. () => void is find and concise, but concern is someone making a mistake when using with other types (e.g. here, doing listenerCleanup: () => void | null instead of listenerCleanup: (() => void) | null).
Anyway just some food for thought.
| return dh.FilterValue.ofNumber( | ||
| TableUtils.removeCommas(value) as unknown as number | ||
| ); |
There was a problem hiding this comment.
Gross. Do we have a follow up ticket to improve JS API? I feel like I commented on this at the time on the JS API review as well as ofNumber needing to take string, but unsure why that wasn't added to the Union type.
There was a problem hiding this comment.
Fixes #1770
Here's the list of changes that weren't just updating the type import
ChartUtils
Console
MonacoProviders
TableSaver
Integer/Decimal/DateTimeColumnFormatter
IrisGridUtils
IrisGrid
IrisGridContextMenuHandler
FormatContextMenuUtils
IrisGridTreeTableModel
IrisGridTableModelTemplate
ServerConfigBootstrap
AuthConfigBootstrap
ConsolePanel, Console, useObjectFetcher
DashboardLayout
FileStorage
IrisGridPanelTypes
Added a blank line to logo.css because of stylelint? Might have accidentally bumped stylelint