Skip to content

Commit 8d7c73f

Browse files
authored
Fix ts assertion error in victory-tooltip.stories.tsx (#2773)
1 parent 8d8755c commit 8d7c73f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

stories/victory-tooltip.stories.tsx

+14-11
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ export const CenterOffset = () => {
167167
labelComponent={
168168
<VictoryTooltip
169169
active
170-
centerOffset={{ y: ({ index }) => (index! < 3 ? -10 : 10), x: 10 }}
170+
centerOffset={{
171+
y: ({ index }) => (Number(index) < 3 ? -10 : 10),
172+
x: 10,
173+
}}
171174
text={`function\noffset`}
172175
/>
173176
}
@@ -215,7 +218,7 @@ export const PointerOrientation = () => {
215218
active
216219
pointerOrientation={({ index }) => (index < 3 ? "bottom" : "top")}
217220
text={({ index }) =>
218-
index! < 3 ? `orientation\nbottom` : `orientation\ntop`
221+
Number(index) < 3 ? `orientation\nbottom` : `orientation\ntop`
219222
}
220223
/>
221224
}
@@ -388,7 +391,7 @@ export const FlyoutHeight = () => {
388391
<VictoryTooltip
389392
active
390393
flyoutHeight={({ text }) => (text === "short" ? 20 : 50)}
391-
text={({ index }) => (index! > 2 ? "short" : "tall")}
394+
text={({ index }) => (Number(index) > 2 ? "short" : "tall")}
392395
/>
393396
}
394397
/>
@@ -445,7 +448,7 @@ export const FlyoutWidth = () => {
445448
<VictoryTooltip
446449
active
447450
flyoutWidth={({ text }) => (text === "short" ? 35 : 100)}
448-
text={({ index }) => (index! > 2 ? "short" : "long")}
451+
text={({ index }) => (Number(index) > 2 ? "short" : "long")}
449452
/>
450453
}
451454
/>
@@ -495,7 +498,7 @@ export const PointerWidth = () => {
495498
labelComponent={
496499
<VictoryTooltip
497500
active
498-
centerOffset={{ x: ({ index }) => (index! < 2 ? -20 : 0) }}
501+
centerOffset={{ x: ({ index }) => (Number(index) < 2 ? -20 : 0) }}
499502
pointerWidth={({ text }) => (text === "skinny" ? 0 : 20)}
500503
text={({ datum }) => (datum.y < 0 ? "skinny" : "wide ")}
501504
/>
@@ -507,7 +510,7 @@ export const PointerWidth = () => {
507510
labelComponent={
508511
<VictoryTooltip
509512
active
510-
centerOffset={{ y: ({ index }) => (index! < 2 ? 20 : 0) }}
513+
centerOffset={{ y: ({ index }) => (Number(index) < 2 ? 20 : 0) }}
511514
pointerWidth={({ text }) => (text === "skinny" ? 0 : 20)}
512515
text={({ datum }) => (datum.y < 0 ? "skinny" : "wide ")}
513516
/>
@@ -522,7 +525,7 @@ export const PointerWidth = () => {
522525
x: ({ index }) => (index === 0 || index === 4 ? 20 : 0),
523526
}}
524527
pointerWidth={({ text }) => (text === "skinny" ? 0 : 20)}
525-
text={({ index }) => (index! > 2 ? "skinny" : "wide ")}
528+
text={({ index }) => (Number(index) > 2 ? "skinny" : "wide ")}
526529
/>
527530
}
528531
/>
@@ -572,7 +575,7 @@ export const PointerLength = () => {
572575
labelComponent={
573576
<VictoryTooltip
574577
active
575-
centerOffset={{ x: ({ index }) => (index! < 2 ? 20 : 0) }}
578+
centerOffset={{ x: ({ index }) => (Number(index) < 2 ? 20 : 0) }}
576579
pointerLength={({ text }) => (text === "short" ? 1 : 30)}
577580
text={({ datum }) => (datum.y < 0 ? "short" : "long ")}
578581
/>
@@ -584,7 +587,7 @@ export const PointerLength = () => {
584587
labelComponent={
585588
<VictoryTooltip
586589
active
587-
centerOffset={{ y: ({ index }) => (index! < 2 ? 20 : 0) }}
590+
centerOffset={{ y: ({ index }) => (Number(index) < 2 ? 20 : 0) }}
588591
pointerLength={({ text }) => (text === "short" ? 1 : 30)}
589592
text={({ datum }) => (datum.y < 0 ? "short" : "long ")}
590593
/>
@@ -599,7 +602,7 @@ export const PointerLength = () => {
599602
x: ({ index }) => (index === 0 || index === 4 ? 20 : 0),
600603
}}
601604
pointerLength={({ text }) => (text === "short" ? 1 : 30)}
602-
text={({ index }) => (index! > 2 ? "short" : "long ")}
605+
text={({ index }) => (Number(index) > 2 ? "short" : "long ")}
603606
/>
604607
}
605608
/>
@@ -656,7 +659,7 @@ export const CornerRadius = () => {
656659
<VictoryTooltip
657660
active
658661
cornerRadius={({ text }) => (text === "square" ? 0 : 5)}
659-
text={({ index }) => (index! > 2 ? "square" : "rounded ")}
662+
text={({ index }) => (Number(index) > 2 ? "square" : "rounded ")}
660663
/>
661664
}
662665
/>

0 commit comments

Comments
 (0)