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

+2-2
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

+2-2
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

+2-2
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

+1-1
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

+3-3
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

+10-10
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

+2-2
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

+19-19
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

+1-1
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

+1-1
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

packages/charts/src/coordinates/Cursor.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import {
1212
} from "../utils";
1313

1414
interface CursorProps {
15-
className?: string;
16-
stroke?: string;
17-
strokeDasharray?: strokeDashTypes;
18-
snapX?: boolean;
19-
opacity?: number;
20-
disableYCursor?: boolean;
21-
useXCursorShape?: boolean;
22-
xCursorShapeFill?: string | any; // func
23-
xCursorShapeStroke: string | any; // func
24-
xCursorShapeStrokeDasharray?: strokeDashTypes;
25-
xCursorShapeOpacity?: number;
15+
readonly className?: string;
16+
readonly disableYCursor?: boolean;
17+
readonly opacity?: number;
18+
readonly snapX?: boolean;
19+
readonly stroke?: string;
20+
readonly strokeDasharray?: strokeDashTypes;
21+
readonly useXCursorShape?: boolean;
22+
readonly xCursorShapeFill?: string | any; // func
23+
readonly xCursorShapeStroke: string | any; // func
24+
readonly xCursorShapeStrokeDasharray?: strokeDashTypes;
25+
readonly xCursorShapeOpacity?: number;
2626
}
2727

2828
const defaultCustomSnapX = (props: CursorProps, moreProps) => {
@@ -136,7 +136,7 @@ class Cursor extends React.Component<CursorProps> {
136136
return disableYCursor ? [xCursor] : [yCursor, xCursor];
137137
}
138138

139-
private readonly drawOnCanvas = (ctx, moreProps) => {
139+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
140140
const cursors = this.getXYCursor(this.props, moreProps);
141141

142142
if (cursors !== undefined) {

packages/charts/src/coordinates/EdgeCoordinate.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ const helper = (props) => {
5050
};
5151

5252
interface EdgeCoordinateProps {
53-
className?: string;
54-
type: "vertical" | "horizontal";
55-
coordinate: any;
56-
x1: number;
57-
y1: number;
58-
x2: number;
59-
y2: number;
60-
orient?: "bottom" | "top" | "left" | "right";
61-
rectWidth?: number;
62-
hideLine?: boolean;
63-
fill?: string;
64-
opacity?: number;
65-
fontFamily: string;
66-
fontSize: number;
53+
readonly className?: string;
54+
readonly type: "vertical" | "horizontal";
55+
readonly coordinate: any;
56+
readonly x1: number;
57+
readonly y1: number;
58+
readonly x2: number;
59+
readonly y2: number;
60+
readonly orient?: "bottom" | "top" | "left" | "right";
61+
readonly rectWidth?: number;
62+
readonly hideLine?: boolean;
63+
readonly fill?: string;
64+
readonly opacity?: number;
65+
readonly fontFamily: string;
66+
readonly fontSize: number;
6767
}
6868

6969
export class EdgeCoordinate extends React.Component<EdgeCoordinateProps> {
@@ -82,7 +82,7 @@ export class EdgeCoordinate extends React.Component<EdgeCoordinateProps> {
8282
arrowWidth: 10,
8383
};
8484

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

8888
const edge = helper(props);

packages/charts/src/coordinates/EdgeCoordinateV2.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function helper(props) {
101101
};
102102
}
103103

104-
export function drawOnCanvas(ctx, props) {
104+
export function drawOnCanvas(ctx: CanvasRenderingContext2D, props) {
105105
const edge = helper(props);
106106

107107
if (edge === null) { return; }

packages/charts/src/coordinates/EdgeCoordinateV3.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function helper(props) {
197197
};
198198
}
199199

200-
export function drawOnCanvas(ctx, props) {
200+
export function drawOnCanvas(ctx: CanvasRenderingContext2D, props) {
201201
const { fontSize, fontFamily } = props;
202202

203203
ctx.font = `${fontSize}px ${fontFamily}`;

packages/charts/src/coordinates/EdgeIndicator.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import { drawOnCanvas, renderSVG } from "./EdgeCoordinateV3";
88
import { first, functor, isDefined, last, noop, strokeDashTypes } from "../utils";
99

1010
interface EdgeIndicatorProps {
11-
yAccessor?: any; // func
12-
type?: "horizontal";
13-
className?: string;
14-
fill?: string | any; // func
15-
lineStroke?: string | any; // func
16-
textFill?: string | any; // func
17-
itemType: "first" | "last";
18-
orient?: "left" | "right";
19-
edgeAt?: "left" | "right";
20-
displayFormat?: any; // func
21-
rectHeight?: number;
22-
rectWidth?: number;
23-
arrowWidth?: number;
24-
lineStrokeDasharray?: strokeDashTypes;
11+
readonly yAccessor?: any; // func
12+
readonly type?: "horizontal";
13+
readonly className?: string;
14+
readonly fill?: string | any; // func
15+
readonly lineStroke?: string | any; // func
16+
readonly textFill?: string | any; // func
17+
readonly itemType: "first" | "last";
18+
readonly orient?: "left" | "right";
19+
readonly edgeAt?: "left" | "right";
20+
readonly displayFormat?: any; // func
21+
readonly rectHeight?: number;
22+
readonly rectWidth?: number;
23+
readonly arrowWidth?: number;
24+
readonly lineStrokeDasharray?: strokeDashTypes;
2525
}
2626

2727
export class EdgeIndicator extends React.Component<EdgeIndicatorProps> {
@@ -64,7 +64,7 @@ export class EdgeIndicator extends React.Component<EdgeIndicatorProps> {
6464
);
6565
}
6666

67-
private readonly drawOnCanvas = (ctx, moreProps) => {
67+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
6868
const edge = this.helper(this.props, moreProps);
6969
const props = {
7070
...this.props,

packages/charts/src/coordinates/MouseCoordinateX.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class MouseCoordinateX extends React.Component<MouseCoordinateXProps> {
6767
);
6868
}
6969

70-
private readonly drawOnCanvas = (ctx, moreProps) => {
70+
private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
7171
const props = this.helper(this.props, moreProps);
7272
if (isNotDefined(props)) { return null; }
7373

0 commit comments

Comments
 (0)