Skip to content

Commit daa6dbd

Browse files
Migrate victory-native to TypeScript (#2739)
Co-authored-by: Charlie Brown <carbonrobot@gmail.com>
1 parent ab3c634 commit daa6dbd

File tree

111 files changed

+1195
-1148
lines changed

Some content is hidden

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

111 files changed

+1195
-1148
lines changed

.changeset/fair-bobcats-knock.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"victory-area": patch
3+
"victory-box-plot": patch
4+
"victory-brush-line": patch
5+
"victory-core": patch
6+
"victory-errorbar": patch
7+
"victory-native": patch
8+
"victory-polar-axis": patch
9+
"victory-scatter": patch
10+
"victory-tooltip": patch
11+
---
12+
13+
Migrate victory-native to TypeScript

config/webpack/webpack.config.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ module.exports = {
2828
cache: true,
2929
context: SRC,
3030
entry: "./index",
31-
externals: [
32-
{
33-
react: {
34-
root: "React",
35-
commonjs2: "react",
36-
commonjs: "react",
37-
amd: "react",
38-
},
31+
externals: {
32+
react: {
33+
root: "React",
34+
commonjs2: "react",
35+
commonjs: "react",
36+
amd: "react",
3937
},
40-
],
38+
"react-native": "react-native",
39+
},
4140
resolve: {
4241
extensions: [".ts", ".tsx", ".js", ".jsx"],
4342
},

packages/victory-area/src/victory-area.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class VictoryAreaBase extends React.Component<VictoryAreaProps> {
9595
),
9696
};
9797

98-
static defaultProps = {
98+
static defaultProps: VictoryAreaProps = {
9999
containerComponent: <VictoryContainer />,
100100
dataComponent: <Area />,
101101
groupComponent: <VictoryClipContainer />,

packages/victory-box-plot/src/victory-box-plot.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class VictoryBoxPlotBase extends React.Component<VictoryBoxPlotProps> {
283283
whiskerWidth: PropTypes.number,
284284
};
285285

286-
static defaultProps = {
286+
static defaultProps: VictoryBoxPlotProps = {
287287
containerComponent: <VictoryContainer />,
288288
data: defaultData,
289289
dataComponent: <Box />,

packages/victory-brush-line/src/victory-brush-line.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ const fallbackProps = {
174174
},
175175
};
176176

177-
export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
177+
export class VictoryBrushLine<
178+
T extends VictoryBrushLineProps,
179+
> extends React.Component<T> {
178180
static propTypes = {
179181
allowDrag: PropTypes.bool,
180182
allowDraw: PropTypes.bool,
@@ -466,7 +468,7 @@ export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
466468
}
467469
return [];
468470
},
469-
onMouseUp(evt, targetProps) {
471+
onMouseUp: (evt, targetProps) => {
470472
const {
471473
onBrushDomainChange,
472474
brushDomain,
@@ -494,7 +496,7 @@ export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
494496
},
495497
];
496498
},
497-
onMouseLeave(evt, targetProps) {
499+
onMouseLeave: (evt, targetProps) => {
498500
const { brushDomain } = targetProps;
499501
return [
500502
{

packages/victory-core/src/victory-clip-container/victory-clip-container.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
7373
clipPathComponent: <ClipPath />,
7474
groupComponent: <g />,
7575
};
76-
private clipId: VictoryClipContainerProps["clipId"];
76+
public clipId: VictoryClipContainerProps["clipId"];
7777

7878
constructor(props: VictoryClipContainerProps) {
7979
super(props);

packages/victory-core/src/victory-container/victory-container.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export interface VictoryContainerProps {
4343
width?: number;
4444
}
4545

46-
export class VictoryContainer extends React.Component<VictoryContainerProps> {
46+
export class VictoryContainer<
47+
TProps extends VictoryContainerProps,
48+
> extends React.Component<TProps> {
4749
static displayName = "VictoryContainer";
4850
static role = "container";
4951
static propTypes = {
@@ -96,7 +98,7 @@ export class VictoryContainer extends React.Component<VictoryContainerProps> {
9698
private containerRef: HTMLElement;
9799
private shouldHandleWheel: boolean;
98100

99-
constructor(props: VictoryContainerProps) {
101+
constructor(props: TProps) {
100102
super(props);
101103
this.containerId =
102104
!isObject(props) || props.containerId === undefined

packages/victory-core/src/victory-portal/portal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Portal
4848
this.forceUpdate();
4949
};
5050

51-
private getChildren() {
51+
public getChildren() {
5252
return keys(this.map).map((key) => {
5353
const el = this.map[key];
5454
return el ? React.cloneElement(el, { key }) : el;

packages/victory-core/src/victory-portal/victory-portal.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export class VictoryPortal extends React.Component<VictoryPortalProps> {
3030

3131
static contextType = PortalContext;
3232
private checkedContext!: boolean;
33-
private renderInPlace!: boolean;
34-
private element!: React.ReactElement;
3533
private portalKey!: number;
34+
public renderInPlace!: boolean;
35+
public element!: React.ReactElement;
3636

3737
componentDidMount() {
3838
if (!this.checkedContext) {

packages/victory-core/src/victory-primitives/arc.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ArcProps extends VictoryCommonPrimitiveProps {
1717
pathComponent?: React.ReactElement;
1818
r?: number;
1919
startAngle?: number;
20+
type?: string;
2021
}
2122

2223
const getArcPath = (props) => {

packages/victory-errorbar/src/victory-errorbar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class VictoryErrorBarBase extends React.Component<VictoryErrorBarProps> {
102102
horizontal: PropTypes.bool,
103103
};
104104

105-
static defaultProps = {
105+
static defaultProps: VictoryErrorBarProps = {
106106
containerComponent: <VictoryContainer />,
107107
data: defaultData,
108108
dataComponent: <ErrorBar />,

0 commit comments

Comments
 (0)