Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(line): use readonly arrays for props as the library does not modify them #2494

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/line/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export interface ComputedDatum {

export interface Serie {
id: string | number
data: Datum[]
data: readonly Datum[]
[key: string]: any
}
export interface ComputedSerie {
id: string | number
data: ComputedDatum[]
data: readonly ComputedDatum[]
color?: string
[key: string]: any
}
Expand All @@ -69,8 +69,8 @@ export interface CustomLayerProps extends Omit<LineSvgProps, 'xScale' | 'yScale'
innerHeight: number
innerWidth: number
lineGenerator: D3Line<ComputedDatum['position']>
points: Point[]
series: ComputedSerie[]
points: readonly Point[]
series: readonly ComputedSerie[]
xScale: Scale<unknown, unknown>
yScale: Scale<unknown, unknown>
}
Expand Down Expand Up @@ -115,7 +115,7 @@ export interface SliceTooltipProps {
x: number
y0: number
y: number
points: Point[]
points: readonly Point[]
}
}
export type SliceTooltip = React.FunctionComponent<SliceTooltipProps>
Expand All @@ -129,14 +129,14 @@ export interface PointSymbolProps {
}

export interface LineProps {
data: Serie[]
data: readonly Serie[]

xScale?: ScaleSpec
xFormat?: ValueFormat<DatumValue>
yScale?: ScaleSpec
yFormat?: ValueFormat<DatumValue>

layers?: Layer[]
layers?: readonly Layer[]

margin?: Box

Expand Down Expand Up @@ -178,7 +178,7 @@ export interface LineProps {
areaOpacity?: number
areaBaselineValue?: DatumValue

markers?: CartesianMarkerProps[]
markers?: readonly CartesianMarkerProps[]

isInteractive?: boolean
onMouseEnter?: PointMouseHandler
Expand All @@ -198,7 +198,7 @@ export interface LineProps {
enableCrosshair?: boolean
crosshairType?: CrosshairType

legends?: LegendProps[]
legends?: readonly LegendProps[]
}

export interface LineSvgProps extends LineProps, MotionProps, SvgDefsAndFill<Datum> {
Expand All @@ -222,7 +222,7 @@ export type CanvasLayer = LineLayerType | CustomCanvasLayer

export interface LineCanvasProps extends Omit<LineProps, 'layers'> {
pixelRatio?: number
layers?: CanvasLayer[]
layers?: readonly CanvasLayer[]
}

export class LineCanvas extends React.Component<LineCanvasProps & Dimensions> {}
Expand Down