Skip to content

Commit

Permalink
Force input types to enforce bigint value if nominalize is true
Browse files Browse the repository at this point in the history
  • Loading branch information
xbtmatt committed Dec 4, 2024
1 parent ac48166 commit fbfff5d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/typescript/frontend/src/components/FormattedNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ const ScrambledNumberLabel = ({
return <span className={className} ref={ref}>{`${prefix}${value}${suffix}`}</span>;
};

type NominalizedBigIntOrAnyNumberString =
| {
value: bigint;
nominalize: true;
}
| {
value: AnyNumberString;
nominalize?: undefined | false;
};

/**
* Formats a number, string or bigint and scrambles it if desired.
*
Expand All @@ -51,11 +61,9 @@ export const FormattedNumber = ({
prefix = "",
className,
style = "sliding-precision",
}: {
value: AnyNumberString;
}: NominalizedBigIntOrAnyNumberString & {
decimals?: number;
scramble?: boolean;
nominalize?: boolean;
suffix?: string;
prefix?: string;
className?: string;
Expand Down

0 comments on commit fbfff5d

Please sign in to comment.