Skip to content

Commit c361e9b

Browse files
authored
fix(sankey): use readonly array types in props (#2701)
The component actually clones data that it mutates, and only iterate over the other arrays, so making them readonly is restricting the props types without any change.
1 parent 3a9d866 commit c361e9b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/sankey/src/types.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export type SankeyNodeDatum<N extends DefaultNode, L extends DefaultLink> = N &
7171
label: string
7272
formattedValue: string
7373
layer: number
74-
sourceLinks: SankeyLinkDatum<N, L>[]
75-
targetLinks: SankeyLinkDatum<N, L>[]
74+
sourceLinks: readonly SankeyLinkDatum<N, L>[]
75+
targetLinks: readonly SankeyLinkDatum<N, L>[]
7676
x: number
7777
y: number
7878
width: number
@@ -81,8 +81,8 @@ export type SankeyNodeDatum<N extends DefaultNode, L extends DefaultLink> = N &
8181

8282
export interface SankeyDataProps<N extends DefaultNode, L extends DefaultLink> {
8383
data: {
84-
nodes: N[]
85-
links: L[]
84+
nodes: readonly N[]
85+
links: readonly L[]
8686
}
8787
}
8888

@@ -110,7 +110,7 @@ export interface SankeyCommonProps<N extends DefaultNode, L extends DefaultLink>
110110
align: SankeyAlignType | SankeyAlignFunction
111111
sort: SankeySortType | SankeySortFunction<N, L>
112112

113-
layers: SankeyLayerId[]
113+
layers: readonly SankeyLayerId[]
114114

115115
margin: Box
116116

@@ -146,7 +146,7 @@ export interface SankeyCommonProps<N extends DefaultNode, L extends DefaultLink>
146146
nodeTooltip: FunctionComponent<{ node: SankeyNodeDatum<N, L> }>
147147
linkTooltip: FunctionComponent<{ link: SankeyLinkDatum<N, L> }>
148148

149-
legends: LegendProps[]
149+
legends: readonly LegendProps[]
150150

151151
renderWrapper: boolean
152152

0 commit comments

Comments
 (0)