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

Migrate victory-native to TypeScript #2739

Merged
merged 17 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions .changeset/fair-bobcats-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"victory-area": patch
"victory-box-plot": patch
"victory-brush-line": patch
"victory-core": patch
"victory-errorbar": patch
"victory-native": patch
"victory-polar-axis": patch
"victory-scatter": patch
"victory-tooltip": patch
---

Migrate victory-native to TypeScript
17 changes: 8 additions & 9 deletions config/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ module.exports = {
cache: true,
context: SRC,
entry: "./index",
externals: [
{
react: {
root: "React",
commonjs2: "react",
commonjs: "react",
amd: "react",
},
externals: {
react: {
root: "React",
commonjs2: "react",
commonjs: "react",
amd: "react",
},
],
"react-native": "react-native",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-area/src/victory-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class VictoryAreaBase extends React.Component<VictoryAreaProps> {
),
};

static defaultProps = {
static defaultProps: VictoryAreaProps = {
containerComponent: <VictoryContainer />,
dataComponent: <Area />,
groupComponent: <VictoryClipContainer />,
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-box-plot/src/victory-box-plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class VictoryBoxPlotBase extends React.Component<VictoryBoxPlotProps> {
whiskerWidth: PropTypes.number,
};

static defaultProps = {
static defaultProps: VictoryBoxPlotProps = {
containerComponent: <VictoryContainer />,
data: defaultData,
dataComponent: <Box />,
Expand Down
8 changes: 5 additions & 3 deletions packages/victory-brush-line/src/victory-brush-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ const fallbackProps = {
},
};

export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
export class VictoryBrushLine<
T extends VictoryBrushLineProps,
> extends React.Component<T> {
static propTypes = {
allowDrag: PropTypes.bool,
allowDraw: PropTypes.bool,
Expand Down Expand Up @@ -466,7 +468,7 @@ export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
}
return [];
},
onMouseUp(evt, targetProps) {
onMouseUp: (evt, targetProps) => {
const {
onBrushDomainChange,
brushDomain,
Expand Down Expand Up @@ -494,7 +496,7 @@ export class VictoryBrushLine extends React.Component<VictoryBrushLineProps> {
},
];
},
onMouseLeave(evt, targetProps) {
onMouseLeave: (evt, targetProps) => {
const { brushDomain } = targetProps;
return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class VictoryClipContainer extends React.Component<VictoryClipContainerPr
clipPathComponent: <ClipPath />,
groupComponent: <g />,
};
private clipId: VictoryClipContainerProps["clipId"];
public clipId: VictoryClipContainerProps["clipId"];

constructor(props: VictoryClipContainerProps) {
super(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export interface VictoryContainerProps {
width?: number;
}

export class VictoryContainer extends React.Component<VictoryContainerProps> {
export class VictoryContainer<
TProps extends VictoryContainerProps,
> extends React.Component<TProps> {
static displayName = "VictoryContainer";
static role = "container";
static propTypes = {
Expand Down Expand Up @@ -96,7 +98,7 @@ export class VictoryContainer extends React.Component<VictoryContainerProps> {
private containerRef: HTMLElement;
private shouldHandleWheel: boolean;

constructor(props: VictoryContainerProps) {
constructor(props: TProps) {
super(props);
this.containerId =
!isObject(props) || props.containerId === undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-core/src/victory-portal/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Portal
this.forceUpdate();
};

private getChildren() {
public getChildren() {
return keys(this.map).map((key) => {
const el = this.map[key];
return el ? React.cloneElement(el, { key }) : el;
Expand Down
4 changes: 2 additions & 2 deletions packages/victory-core/src/victory-portal/victory-portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class VictoryPortal extends React.Component<VictoryPortalProps> {

static contextType = PortalContext;
private checkedContext!: boolean;
private renderInPlace!: boolean;
private element!: React.ReactElement;
private portalKey!: number;
public renderInPlace!: boolean;
public element!: React.ReactElement;

componentDidMount() {
if (!this.checkedContext) {
Expand Down
1 change: 1 addition & 0 deletions packages/victory-core/src/victory-primitives/arc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ArcProps extends VictoryCommonPrimitiveProps {
pathComponent?: React.ReactElement;
r?: number;
startAngle?: number;
type?: string;
}

const getArcPath = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-errorbar/src/victory-errorbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class VictoryErrorBarBase extends React.Component<VictoryErrorBarProps> {
horizontal: PropTypes.bool,
};

static defaultProps = {
static defaultProps: VictoryErrorBarProps = {
containerComponent: <VictoryContainer />,
data: defaultData,
dataComponent: <ErrorBar />,
Expand Down
Loading
Loading