Skip to content

Commit f22fb3c

Browse files
committed
fix(props): correcting more props
Adding readonly to props. Making props optional if they have a default prop.
1 parent 79f1205 commit f22fb3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1011
-949
lines changed

packages/charts/src/CanvasContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as React from "react";
33
import { isDefined } from "./utils";
44

55
interface CanvasContainerProps {
6-
readonly width: number;
76
readonly height: number;
7+
readonly ratio: number;
88
readonly type: string;
9+
readonly width: number;
910
readonly zIndex?: number;
10-
readonly ratio: number;
1111
}
1212

1313
class CanvasContainer extends React.Component<CanvasContainerProps> {

packages/charts/src/GenericChartComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class GenericChartComponent extends GenericComponent {
5252
this.preEvaluate = this.preEvaluate.bind(this);
5353
}
5454

55-
public preCanvasDraw(ctx, moreProps) {
55+
public preCanvasDraw(ctx: CanvasRenderingContext2D, moreProps) {
5656

5757
super.preCanvasDraw(ctx, moreProps);
5858

@@ -83,7 +83,7 @@ class GenericChartComponent extends GenericComponent {
8383
}
8484
}
8585

86-
public postCanvasDraw(ctx, moreProps) {
86+
public postCanvasDraw(ctx: CanvasRenderingContext2D, moreProps) {
8787
super.postCanvasDraw(ctx, moreProps);
8888
ctx.restore();
8989
}

packages/charts/src/GenericComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ class GenericComponent extends React.Component<GenericComponentProps, GenericCom
453453
return (morePropsDecorator || identity)(moreProps);
454454
}
455455

456-
public preCanvasDraw(ctx, moreProps) {
456+
public preCanvasDraw(ctx: CanvasRenderingContext2D, moreProps) {
457457
// do nothing
458458
}
459459

460-
public postCanvasDraw(ctx, moreProps) {
460+
public postCanvasDraw(ctx: CanvasRenderingContext2D, moreProps) {
461461
// empty
462462
}
463463

packages/charts/src/annotation/BackgroundText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class BackgroundText extends PureComponent<BackgroundTextProps> {
6666
);
6767
}
6868

69-
private readonly drawOnCanvas = (ctx, props, { interval }, getText) => {
69+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, props, { interval }, getText) => {
7070
ctx.clearRect(-1, -1, ctx.canvas.width + 2, ctx.canvas.height + 2);
7171
ctx.save();
7272

packages/charts/src/annotation/Label.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Label extends React.Component<LabelProps> {
5454
);
5555
}
5656

57-
private readonly drawOnCanvas = (ctx, moreProps) => {
57+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
5858
drawOnCanvas2(ctx, this.props, this.context, moreProps);
5959
}
6060

@@ -77,7 +77,7 @@ function getYScale(chartConfig) {
7777
return Array.isArray(chartConfig) ? undefined : chartConfig.yScale;
7878
}
7979

80-
function drawOnCanvas2(ctx, props, context, moreProps) {
80+
function drawOnCanvas2(ctx: CanvasRenderingContext2D, props, context, moreProps) {
8181
ctx.save();
8282

8383
const { canvasOriginX, canvasOriginY, margin, ratio } = context;
@@ -96,7 +96,7 @@ function drawOnCanvas2(ctx, props, context, moreProps) {
9696

9797
}
9898

99-
function drawOnCanvas(ctx, props, moreProps) {
99+
function drawOnCanvas(ctx: CanvasRenderingContext2D, props, moreProps) {
100100
const { textAnchor, fontFamily, fontSize, opacity, rotate } = props;
101101
const { xScale, chartConfig, xAccessor } = moreProps;
102102

packages/charts/src/axes/AxisLine.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import * as React from "react";
22
import { colorToRGBA, first, last } from "../utils";
33

44
interface AxisLineProps {
5-
className?: string;
6-
shapeRendering?: string;
7-
orient: string;
8-
scale: any; // func
9-
outerTickSize?: number;
10-
fill?: string;
11-
stroke?: string;
12-
strokeWidth?: number;
13-
opacity?: number;
14-
range: number[];
5+
readonly className?: string;
6+
readonly shapeRendering?: string;
7+
readonly orient: string;
8+
readonly scale: any; // func
9+
readonly outerTickSize?: number;
10+
readonly fill?: string;
11+
readonly stroke?: string;
12+
readonly strokeWidth?: number;
13+
readonly opacity?: number;
14+
readonly range: number[];
1515
}
1616

1717
export class AxisLine extends React.Component<AxisLineProps> {

packages/charts/src/axes/AxisTicks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface TickProps {
2626

2727
class Tick extends React.Component<TickProps> {
2828

29-
public static drawOnCanvasStatic = (tick, ctx, result) => {
29+
public static drawOnCanvasStatic = (tick, ctx: CanvasRenderingContext2D, result) => {
3030
const { scale, tickTransform, canvas_dy, x, y, x2, y2, format } = result;
3131

3232
const origin = tickTransform(scale, tick);
@@ -82,7 +82,7 @@ export class AxisTicks extends React.Component<AxisTicksProps> {
8282
tickStrokeOpacity: 1,
8383
};
8484

85-
public static drawOnCanvasStatic = (props, ctx, xScale, yScale) => {
85+
public static drawOnCanvasStatic = (props, ctx: CanvasRenderingContext2D, xScale, yScale) => {
8686
props = { ...AxisTicks.defaultProps, ...props };
8787

8888
const { orient } = props;

packages/charts/src/axes/AxisZoomCapture.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@ import {
1919
} from "../utils";
2020

2121
interface AxisZoomCaptureProps {
22-
innerTickSize?: number;
23-
outerTickSize?: number;
24-
tickFormat?: any; // func
25-
tickPadding?: number;
26-
tickSize?: number;
27-
ticks?: number;
28-
tickValues?: number[];
29-
showDomain?: boolean;
30-
showTicks?: boolean;
31-
className?: string;
32-
axisZoomCallback?: any; // func
33-
inverted?: boolean;
34-
bg: {
22+
readonly innerTickSize?: number;
23+
readonly outerTickSize?: number;
24+
readonly tickFormat?: any; // func
25+
readonly tickPadding?: number;
26+
readonly tickSize?: number;
27+
readonly ticks?: number;
28+
readonly tickValues?: number[];
29+
readonly showDomain?: boolean;
30+
readonly showTicks?: boolean;
31+
readonly className?: string;
32+
readonly axisZoomCallback?: any; // func
33+
readonly inverted?: boolean;
34+
readonly bg: {
3535
h: number;
3636
x: number;
3737
w: number;
3838
y: number;
3939
};
40-
zoomCursorClassName?: string;
41-
getMoreProps: any; // func
42-
getScale: any; // func
43-
getMouseDelta: any; // func
44-
onDoubleClick: any; // func
45-
onContextMenu: any; // func
40+
readonly zoomCursorClassName?: string;
41+
readonly getMoreProps: any; // func
42+
readonly getScale: any; // func
43+
readonly getMouseDelta: any; // func
44+
readonly onDoubleClick: any; // func
45+
readonly onContextMenu: any; // func
4646
}
4747

4848
interface AxisZoomCaptureState {

packages/charts/src/coordinates/CrossHairCursor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class CrossHairCursor extends React.Component<CrossHairCursorProps> {
6666
);
6767
}
6868

69-
private readonly drawOnCanvas = (ctx, moreProps) => {
69+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
7070
const lines = this.helper(this.props, moreProps);
7171

7272
if (lines !== undefined && isDefined(lines)) {

packages/charts/src/coordinates/CurrentCoordinate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CurrentCoordinate extends React.Component<CurrentCoordinateProps> {
2929
);
3030
}
3131

32-
private readonly drawOnCanvas = (ctx, moreProps) => {
32+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
3333
const circle = this.helper(this.props, moreProps);
3434
if (!circle) { return null; }
3535

0 commit comments

Comments
 (0)