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

Type cleanups #4042

Merged
merged 13 commits into from
Feb 14, 2024
Merged

Type cleanups #4042

merged 13 commits into from
Feb 14, 2024

Conversation

bcolloran
Copy link
Contributor

@bcolloran bcolloran commented Feb 13, 2024

part of #3424, hopefully helps with #3989, but it's not clear what exactly is causing that error.

Note that per conversation with @djbarnwal we're updating MetricsExplorerEntity.selectedTimezone to
(a) be required, not optional)
(b) default to "UTC" if not specified,
(c) use the value "UTC" in preference to "Etc/UTC" in all cases

$: comparisonPercChange =
comparisonValue && value !== undefined && value !== null
? (value - comparisonValue) / comparisonValue
: undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

calculate comparisonPercChange here, no need to pass it down from parent

expandedMeasureName
? (measure) => measure.name === expandedMeasureName
: (_, i) => $showHideMeasures.selectedItems[i],
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

consolidating into one declaration allows automatic type inference

@bcolloran bcolloran self-assigned this Feb 13, 2024
@@ -34,7 +35,7 @@ A simple composable container for SVG-based data graphics.
export let shareYScale = true;

export let mouseoverValue: DomainCoordinates | undefined = undefined;
export let hovered = undefined;
export let hovered = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@djbarnwal -- I believe that hover state should always default to false unless explicitly set (here and in other files), rather than using undefined. Please LMK if that will cause any problems

Copy link
Member

Choose a reason for hiding this comment

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

Sounds about right. Shouldn't cause any issue.

@@ -1,7 +1,7 @@
export interface Point {
x: number;
y: number;
value: string;
value?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is already treated as optional, there are guards against it being undefined in web-common/src/components/data-graphic/marks/MultiMetricMouseoverLabel.svelte line 204

xType: string; // FIXME: we should have an enum here
yType: string; // FIXME: we should have an enum here
xType: ScaleType;
yType: ScaleType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed this ancient FIXME

export let highlightedCol: number;
export let scrubPos: { start: number; end: number };
export let highlightedCol: number | undefined;
export let scrubPos: { start?: number; end?: number };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

already treated as optional, see check below

Copy link
Member

@djbarnwal djbarnwal left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanups. Looks good.

// for at least 19 months, so hopefully it's safe enough.
// In any case, this cascading context store approach is
// ridiculously over engineered and needs to be rethought
} as SimpleDataGraphicConfigurationArguments;
Copy link
Member

Choose a reason for hiding this comment

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

Just to add, this is most probably not a safe cast. I remember seeing missing properties at couple of places some time back. We should get back to this when we have more bandwidth to handle our tech debt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for flagging this @djbarnwal !!! -- since you know this is unsafe for sure, I'm going to remove this cast before merging

@@ -34,7 +35,7 @@ A simple composable container for SVG-based data graphics.
export let shareYScale = true;

export let mouseoverValue: DomainCoordinates | undefined = undefined;
export let hovered = undefined;
export let hovered = false;
Copy link
Member

Choose a reason for hiding this comment

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

Sounds about right. Shouldn't cause any issue.

@bcolloran bcolloran merged commit c735dbd into main Feb 14, 2024
4 checks passed
@bcolloran bcolloran deleted the more-type-cleanups branch February 14, 2024 18:02
mindspank pushed a commit that referenced this pull request Feb 23, 2024
* Type cleanups

* replace "Etc/UTC" -> "UTC"

* correct types on TDDTable

* use enum for scale type

* finish replacing scaleType enum

* fix domain coordinate types

* finish setting default for selectedTimezone

* add default for selectedTimeZone

* fix enum import problem

* make "value" optional

* update svelte-check exclusions

* cleanups

* remove unsafe cast
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.

2 participants