Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,20 @@ export default function transformProps(

const { setDataMask = () => {}, onContextMenu } = hooks;

const min = minVal ?? calculateMin(transformedData);
const max = maxVal ?? calculateMax(transformedData);
const isValidNumber = (
val: number | null | undefined | string,
): val is number => {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

The type predicate val is number is inaccurate since the function returns true when val is a valid numeric string (e.g., '10'). While lines 234 and 237 handle this correctly with Number(minVal) and Number(maxVal), the type guard is misleading.

Consider changing the return type to accurately reflect what the function validates:

const isValidNumber = (
  val: number | null | undefined | string,
): val is number | string => {

Or, alternatively, be more precise and only accept actual numbers in the type guard:

const isValidNumber = (
  val: number | null | undefined | string,
): boolean => {
Suggested change
): val is number => {
): boolean => {

Copilot uses AI. Check for mistakes.
if (val == null || val === '') return false;
const num = typeof val === 'string' ? Number(val) : val;
return !Number.isNaN(num) && Number.isFinite(num);
};

const min = isValidNumber(minVal)
? Number(minVal)
: calculateMin(transformedData);
const max = isValidNumber(maxVal)
? Number(maxVal)
: calculateMax(transformedData);
const axisLabels = range(min, max, (max - min) / splitNumber);
const axisLabelLength = Math.max(
...axisLabels.map(label => numberFormatter(label).length).concat([1]),
Expand Down
Loading
Loading