From 6dc6636cb64135104264547f05a3f44c787c6508 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Tue, 14 Nov 2023 08:53:47 +0100 Subject: [PATCH] fix(pie): use readonly arrays for props as the library does not modify them --- packages/pie/src/hooks.ts | 2 +- packages/pie/src/types.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/pie/src/hooks.ts b/packages/pie/src/hooks.ts index 0acb29bf9..83be94273 100644 --- a/packages/pie/src/hooks.ts +++ b/packages/pie/src/hooks.ts @@ -31,7 +31,7 @@ export const useNormalizedData = ({ Omit, 'arc' | 'color' | 'fill'> >, }: Pick, 'id' | 'value' | 'valueFormat' | 'colors'> & { - data: RawDatum[] + data: readonly RawDatum[] }): Omit, 'arc' | 'fill'>[] => { const getId = usePropertyAccessor(id) const getValue = usePropertyAccessor(value) diff --git a/packages/pie/src/types.ts b/packages/pie/src/types.ts index 2fb75d4a4..66f926e8b 100644 --- a/packages/pie/src/types.ts +++ b/packages/pie/src/types.ts @@ -58,7 +58,7 @@ export interface ComputedDatum { } export interface DataProps { - data: RawDatum[] + data: readonly RawDatum[] } export interface PieTooltipProps { @@ -73,7 +73,7 @@ export type MouseEventHandler = ( export type PieLayerId = 'arcLinkLabels' | 'arcs' | 'arcLabels' | 'legends' export interface PieCustomLayerProps { - dataWithArc: ComputedDatum[] + dataWithArc: readonly ComputedDatum[] centerX: number centerY: number radius: number @@ -114,7 +114,7 @@ export type CommonPieProps = { isInteractive: boolean tooltip: React.FC> - legends: LegendProps[] + legends: readonly LegendProps[] role: string renderWrapper: boolean @@ -137,7 +137,7 @@ export type PieSvgProps = DataProps & Partial> & SvgDefsAndFill> & PieHandlers & { - layers?: PieLayer[] + layers?: readonly PieLayer[] animate?: boolean motionConfig?: MotionProps['motionConfig'] transitionMode?: ArcTransitionMode @@ -148,7 +148,7 @@ export type CompletePieSvgProps = DataProps & CommonPieProps & SvgDefsAndFill> & PieHandlers & { - layers: PieLayer[] + layers: readonly PieLayer[] animate: boolean motionConfig: MotionProps['motionConfig'] transitionMode: ArcTransitionMode