Skip to content

Commit e2700de

Browse files
markov00nickofthyme
authored andcommitted
refactor(typings): prepare for upgrade TS to 3.7 (#402)
Fix issues related to typescript `3.7` BREAKING CHANGE: We have a few exported styles, used in the Theme that are changed: SharedGeometryStyle to SharedGeometryStateStyle and GeometryStyle to GeometryStateStyle
1 parent 3bf5fd5 commit e2700de

File tree

12 files changed

+133
-138
lines changed

12 files changed

+133
-138
lines changed

.ci/jobs/defaults.yml

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
##### GLOBAL METADATA
43

54
- meta:
@@ -12,65 +11,65 @@
1211
daysToKeep: 30
1312
numToKeep: 100
1413
properties:
15-
- github:
16-
url: https://github.com/elastic/elastic-charts/
17-
- inject:
18-
properties-content: 'HOME=$JENKINS_HOME
14+
- github:
15+
url: https://github.com/elastic/elastic-charts/
16+
- inject:
17+
properties-content: 'HOME=$JENKINS_HOME
1918
20-
'
19+
'
2120
concurrent: true
2221
node: linux && docker
2322
scm:
24-
- git:
25-
name: origin
26-
credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba
27-
reference-repo: /var/lib/jenkins/.git-references/elastic-charts.git
28-
branches:
29-
- ${ghprbActualCommit}
30-
url: git@github.com:elastic/elastic-charts.git
31-
refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*
32-
basedir: ''
33-
wipe-workspace: 'True'
23+
- git:
24+
name: origin
25+
credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba
26+
reference-repo: /var/lib/jenkins/.git-references/elastic-charts.git
27+
branches:
28+
- ${ghprbActualCommit}
29+
url: git@github.com:elastic/elastic-charts.git
30+
refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*
31+
basedir: ''
32+
wipe-workspace: 'True'
3433
triggers:
35-
- github-pull-request:
36-
org-list:
37-
- elastic
38-
allow-whitelist-orgs-as-admins: true
39-
github-hooks: true
40-
status-context: kibana-ci
41-
cancel-builds-on-update: true
34+
- github-pull-request:
35+
org-list:
36+
- elastic
37+
allow-whitelist-orgs-as-admins: true
38+
github-hooks: true
39+
status-context: kibana-ci
40+
cancel-builds-on-update: true
4241
vault:
4342
role_id: 443f9500-f443-19ba-d698-1a48e104f8ba
4443
wrappers:
45-
- ansicolor
46-
- timeout:
47-
type: absolute
48-
timeout: 180
49-
fail: true
50-
- timestamps
44+
- ansicolor
45+
- timeout:
46+
type: absolute
47+
timeout: 180
48+
fail: true
49+
- timestamps
5150
builders:
52-
- shell: |-
53-
#!/usr/local/bin/runbld
51+
- shell: |-
52+
#!/usr/local/bin/runbld
5453
55-
set -euo pipefail
54+
set -euo pipefail
5655
57-
set +x
58-
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
59-
unset VAULT_ROLE_ID VAULT_SECRET_ID
60-
export CODECOV_TOKEN=$(vault read -field=token secret/kibana-issues/prod/codecov)
61-
unset VAULT_TOKEN
62-
set -x
56+
set +x
57+
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
58+
unset VAULT_ROLE_ID VAULT_SECRET_ID
59+
export CODECOV_TOKEN=$(vault read -field=token secret/kibana-issues/prod/codecov)
60+
unset VAULT_TOKEN
61+
set -x
6362
64-
./.ci/run.sh
63+
./.ci/run.sh
6564
publishers:
66-
- email:
67-
recipients: infra-root+build@elastic.co
68-
- google-cloud-storage:
69-
credentials-id: kibana-ci-gcs-plugin
70-
uploads:
71-
- classic:
72-
file-pattern: integration/**/__diff_output__/**/*
73-
storage-location: gs://kibana-ci-artifacts/jobs/$JOB_NAME/$BUILD_NUMBER
74-
share-publicly: true
75-
upload-for-failed-jobs: true
76-
show-inline: true
65+
- email:
66+
recipients: infra-root+build@elastic.co
67+
- google-cloud-storage:
68+
credentials-id: kibana-ci-gcs-plugin
69+
uploads:
70+
- classic:
71+
file-pattern: integration/**/__diff_output__/**/*
72+
storage-location: gs://kibana-ci-artifacts/jobs/$JOB_NAME/$BUILD_NUMBER
73+
share-publicly: true
74+
upload-for-failed-jobs: true
75+
show-inline: true

integration/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"extends": "../tsconfig",
3-
"include": [
4-
"./**/*"
5-
]
3+
"include": ["./**/*"]
64
}

src/chart_types/xy_chart/rendering/rendering.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { getSpecId } from '../../../utils/ids';
22
import {
33
BarGeometry,
4-
getGeometryStyle,
4+
getGeometryStateStyle,
55
isPointOnGeometry,
66
PointGeometry,
77
getBarStyleOverrides,
88
GeometryId,
99
getPointStyleOverrides,
1010
} from './rendering';
11-
import { BarSeriesStyle, SharedGeometryStyle, PointStyle } from '../../../utils/themes/theme';
11+
import { BarSeriesStyle, SharedGeometryStateStyle, PointStyle } from '../../../utils/themes/theme';
1212
import { DataSeriesDatum } from '../utils/series';
1313
import { RecursivePartial, mergePartial } from '../../../utils/commons';
1414

@@ -122,7 +122,7 @@ describe('Rendering utils', () => {
122122
},
123123
};
124124

125-
const sharedThemeStyle: SharedGeometryStyle = {
125+
const sharedThemeStyle: SharedGeometryStateStyle = {
126126
default: {
127127
opacity: 1,
128128
},
@@ -135,41 +135,41 @@ describe('Rendering utils', () => {
135135
};
136136

137137
// no highlighted elements
138-
const defaultStyle = getGeometryStyle(geometryId, null, sharedThemeStyle);
138+
const defaultStyle = getGeometryStateStyle(geometryId, null, sharedThemeStyle);
139139
expect(defaultStyle).toBe(sharedThemeStyle.default);
140140

141141
// should equal highlighted opacity
142-
const highlightedStyle = getGeometryStyle(geometryId, highlightedLegendItem, sharedThemeStyle);
142+
const highlightedStyle = getGeometryStateStyle(geometryId, highlightedLegendItem, sharedThemeStyle);
143143
expect(highlightedStyle).toBe(sharedThemeStyle.highlighted);
144144

145145
// should equal unhighlighted opacity
146-
const unhighlightedStyle = getGeometryStyle(geometryId, unhighlightedLegendItem, sharedThemeStyle);
146+
const unhighlightedStyle = getGeometryStateStyle(geometryId, unhighlightedLegendItem, sharedThemeStyle);
147147
expect(unhighlightedStyle).toBe(sharedThemeStyle.unhighlighted);
148148

149149
// should equal custom spec highlighted opacity
150-
const customHighlightedStyle = getGeometryStyle(geometryId, highlightedLegendItem, sharedThemeStyle);
150+
const customHighlightedStyle = getGeometryStateStyle(geometryId, highlightedLegendItem, sharedThemeStyle);
151151
expect(customHighlightedStyle).toBe(sharedThemeStyle.highlighted);
152152

153153
// unhighlighted elements remain unchanged with custom opacity
154-
const customUnhighlightedStyle = getGeometryStyle(geometryId, unhighlightedLegendItem, sharedThemeStyle);
154+
const customUnhighlightedStyle = getGeometryStateStyle(geometryId, unhighlightedLegendItem, sharedThemeStyle);
155155
expect(customUnhighlightedStyle).toBe(sharedThemeStyle.unhighlighted);
156156

157157
// has individual highlight
158-
const hasIndividualHighlight = getGeometryStyle(geometryId, null, sharedThemeStyle, {
158+
const hasIndividualHighlight = getGeometryStateStyle(geometryId, null, sharedThemeStyle, {
159159
hasHighlight: true,
160160
hasGeometryHover: true,
161161
});
162162
expect(hasIndividualHighlight).toBe(sharedThemeStyle.highlighted);
163163

164164
// no highlight
165-
const noHighlight = getGeometryStyle(geometryId, null, sharedThemeStyle, {
165+
const noHighlight = getGeometryStateStyle(geometryId, null, sharedThemeStyle, {
166166
hasHighlight: false,
167167
hasGeometryHover: true,
168168
});
169169
expect(noHighlight).toBe(sharedThemeStyle.unhighlighted);
170170

171171
// no geometry hover
172-
const noHover = getGeometryStyle(geometryId, null, sharedThemeStyle, {
172+
const noHover = getGeometryStateStyle(geometryId, null, sharedThemeStyle, {
173173
hasHighlight: true,
174174
hasGeometryHover: false,
175175
});

src/chart_types/xy_chart/rendering/rendering.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import {
77
LineSeriesStyle,
88
LineStyle,
99
PointStyle,
10-
SharedGeometryStyle,
10+
SharedGeometryStateStyle,
1111
BarSeriesStyle,
12+
GeometryStateStyle,
1213
} from '../../../utils/themes/theme';
1314
import { SpecId } from '../../../utils/ids';
1415
import { isLogarithmicScale } from '../../../utils/scales/scale_continuous';
@@ -41,16 +42,6 @@ export interface GeometryValue {
4142
accessor: AccessorType;
4243
}
4344

44-
/** Shared style properties for varies geometries */
45-
export interface GeometryStyle {
46-
/**
47-
* Opacity multiplier
48-
*
49-
* if set to `0.5` all given opacities will be halfed
50-
*/
51-
opacity: number;
52-
}
53-
5445
export type IndexedGeometry = PointGeometry | BarGeometry;
5546

5647
export interface PointGeometry {
@@ -560,12 +551,12 @@ export function renderArea(
560551
};
561552
}
562553

563-
export function getGeometryStyle(
554+
export function getGeometryStateStyle(
564555
geometryId: GeometryId,
565556
highlightedLegendItem: LegendItem | null,
566-
sharedGeometryStyle: SharedGeometryStyle,
557+
sharedGeometryStyle: SharedGeometryStateStyle,
567558
individualHighlight?: { [key: string]: boolean },
568-
): GeometryStyle {
559+
): GeometryStateStyle {
569560
const { default: defaultStyles, highlighted, unhighlighted } = sharedGeometryStyle;
570561

571562
if (highlightedLegendItem != null) {

src/chart_types/xy_chart/utils/series.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ export function getRawDataSeries(
281281
areaSeries: 0,
282282
};
283283
const seriesSpecsCount = seriesSpecs.length;
284-
let i;
285-
for (i = 0; i < seriesSpecsCount; i++) {
284+
let i = 0;
285+
for (; i < seriesSpecsCount; i++) {
286286
const spec = seriesSpecs[i];
287287
const { id, seriesType } = spec;
288288
const ds = dataSeries.get(id);

src/components/react_canvas/area_geometries.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { Circle, Group, Path } from 'react-konva';
44
import { LegendItem } from '../../chart_types/xy_chart/legend/legend';
55
import {
66
AreaGeometry,
7-
getGeometryStyle,
7+
getGeometryStateStyle,
88
PointGeometry,
99
getGeometryIdKey,
1010
GeometryId,
1111
} from '../../chart_types/xy_chart/rendering/rendering';
12-
import { SharedGeometryStyle, PointStyle } from '../../utils/themes/theme';
12+
import { SharedGeometryStateStyle, PointStyle } from '../../utils/themes/theme';
1313
import {
1414
buildAreaRenderProps,
1515
buildPointStyleProps,
@@ -22,7 +22,7 @@ import { mergePartial } from '../../utils/commons';
2222
interface AreaGeometriesDataProps {
2323
animated?: boolean;
2424
areas: AreaGeometry[];
25-
sharedStyle: SharedGeometryStyle;
25+
sharedStyle: SharedGeometryStateStyle;
2626
highlightedLegendItem: LegendItem | null;
2727
clippings: ContainerConfig;
2828
}
@@ -59,23 +59,23 @@ export class AreaGeometries extends React.PureComponent<AreaGeometriesDataProps,
5959
acc.push(this.renderAreaLines(glyph, i, sharedStyle, highlightedLegendItem, clippings));
6060
}
6161
if (seriesPointStyle.visible) {
62-
const geometryStyle = getGeometryStyle(geometryId, this.props.highlightedLegendItem, sharedStyle);
63-
const pointStyleProps = buildPointStyleProps(glyph.color, seriesPointStyle, geometryStyle);
62+
const geometryStateStyle = getGeometryStateStyle(geometryId, this.props.highlightedLegendItem, sharedStyle);
63+
const pointStyleProps = buildPointStyleProps(glyph.color, seriesPointStyle, geometryStateStyle);
6464
acc.push(...this.renderPoints(glyph.points, i, pointStyleProps, glyph.geometryId));
6565
}
6666
return acc;
6767
}, []);
6868
};
6969
private renderArea = (
7070
glyph: AreaGeometry,
71-
sharedStyle: SharedGeometryStyle,
71+
sharedStyle: SharedGeometryStateStyle,
7272
highlightedLegendItem: LegendItem | null,
7373
clippings: ContainerConfig,
7474
): JSX.Element => {
7575
const { area, color, transform, geometryId, seriesAreaStyle } = glyph;
76-
const geometryStyle = getGeometryStyle(geometryId, highlightedLegendItem, sharedStyle);
76+
const geometryStateStyle = getGeometryStateStyle(geometryId, highlightedLegendItem, sharedStyle);
7777
const key = getGeometryIdKey(geometryId, 'area-');
78-
const areaProps = buildAreaRenderProps(transform.x, area, color, seriesAreaStyle, geometryStyle);
78+
const areaProps = buildAreaRenderProps(transform.x, area, color, seriesAreaStyle, geometryStateStyle);
7979
return (
8080
<Group {...clippings} key={key}>
8181
<Path {...areaProps} />
@@ -85,16 +85,16 @@ export class AreaGeometries extends React.PureComponent<AreaGeometriesDataProps,
8585
private renderAreaLines = (
8686
glyph: AreaGeometry,
8787
areaIndex: number,
88-
sharedStyle: SharedGeometryStyle,
88+
sharedStyle: SharedGeometryStateStyle,
8989
highlightedLegendItem: LegendItem | null,
9090
clippings: ContainerConfig,
9191
): JSX.Element => {
9292
const { lines, color, geometryId, transform, seriesAreaLineStyle } = glyph;
93-
const geometryStyle = getGeometryStyle(geometryId, highlightedLegendItem, sharedStyle);
93+
const geometryStateStyle = getGeometryStateStyle(geometryId, highlightedLegendItem, sharedStyle);
9494
const groupKey = getGeometryIdKey(geometryId, `area-line-${areaIndex}`);
9595
const linesElements = lines.map<JSX.Element>((linePath, lineIndex) => {
9696
const key = getGeometryIdKey(geometryId, `area-line-${areaIndex}-${lineIndex}`);
97-
const lineProps = buildLineRenderProps(transform.x, linePath, color, seriesAreaLineStyle, geometryStyle);
97+
const lineProps = buildLineRenderProps(transform.x, linePath, color, seriesAreaLineStyle, geometryStateStyle);
9898
return <Path {...lineProps} key={key} />;
9999
});
100100
return (

src/components/react_canvas/bar_geometries.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import React from 'react';
33
import { Group, Rect } from 'react-konva';
44
import { animated, Spring } from 'react-spring/renderprops-konva.cjs';
55
import { LegendItem } from '../../chart_types/xy_chart/legend/legend';
6-
import { BarGeometry, getGeometryStyle } from '../../chart_types/xy_chart/rendering/rendering';
7-
import { SharedGeometryStyle } from '../../utils/themes/theme';
6+
import { BarGeometry, getGeometryStateStyle } from '../../chart_types/xy_chart/rendering/rendering';
7+
import { SharedGeometryStateStyle } from '../../utils/themes/theme';
88
import { buildBarRenderProps, buildBarBorderRenderProps } from './utils/rendering_props_utils';
99

1010
interface BarGeometriesDataProps {
1111
animated?: boolean;
1212
bars: BarGeometry[];
13-
sharedStyle: SharedGeometryStyle;
13+
sharedStyle: SharedGeometryStateStyle;
1414
highlightedLegendItem: LegendItem | null;
1515
clippings: ContainerConfig;
1616
}
@@ -52,7 +52,7 @@ export class BarGeometries extends React.PureComponent<BarGeometriesDataProps, B
5252
hasHighlight,
5353
};
5454

55-
const geometryStyle = getGeometryStyle(
55+
const geometryStyle = getGeometryStateStyle(
5656
bar.geometryId,
5757
this.props.highlightedLegendItem,
5858
sharedStyle,

0 commit comments

Comments
 (0)