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(core): use readonly arrays for props as the libraries do not modify them #2588

Merged
merged 1 commit into from
May 12, 2024
Merged
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
14 changes: 7 additions & 7 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export type BoxAlign =
| 'bottom'
| 'bottom-left'
| 'left'
export const boxAlignments: BoxAlign[]
export const boxAlignments: readonly BoxAlign[]
export function alignBox(box: AlignBox, container: AlignBox, alignment: BoxAlign): [number, number]

export type GetColor<T> = (datum: T) => string
export type Colors = string[] | string
export type Colors = readonly string[] | string
export interface ColorProps<T> {
colors?: Colors
colorBy?: string | GetColor<T>
Expand Down Expand Up @@ -278,11 +278,11 @@ export function useMotionConfig(): {

export type SvgFillMatcher<T> = (datum: T) => boolean
export interface SvgDefsAndFill<T> {
defs?: {
defs?: readonly {
id: string
[key: string]: any
}[]
fill?: { id: string; match: Record<string, unknown> | SvgFillMatcher<T> | '*' }[]
fill?: readonly { id: string; match: Record<string, unknown> | SvgFillMatcher<T> | '*' }[]
}

export type CssMixBlendMode =
Expand Down Expand Up @@ -394,7 +394,7 @@ export function PatternLines(props: Omit<PatternLinesDef, 'type'>): JSX.Element
export type Def = LinearGradientDef | PatternDotsDef | PatternSquaresDef | PatternLinesDef

export type DefsProps = {
defs: Def[]
defs: readonly Def[]
}

export function Defs(props: DefsProps): JSX.Element
Expand Down Expand Up @@ -547,7 +547,7 @@ interface CartesianMarkersProps<
height: number
xScale: (value: X) => number
yScale: (value: Y) => number
markers: CartesianMarkerProps<X | Y>[]
markers: readonly CartesianMarkerProps<X | Y>[]
}
type CartesianMarkersType = <X extends DatumValue = DatumValue, Y extends DatumValue = DatumValue>(
props: CartesianMarkersProps<X, Y>
Expand Down Expand Up @@ -605,7 +605,7 @@ export type ClosedCurveFactoryId =
| 'cardinalClosed'
| 'catmullRomClosed'
| 'linearClosed'
export const closedCurvePropKeys: ClosedCurveFactoryId[]
export const closedCurvePropKeys: readonly ClosedCurveFactoryId[]

export const curveFromProp: (interpolation: CurveFactoryId) => CurveFactory

Expand Down
Loading