Skip to content

Commit 459d0ed

Browse files
authored
🤖 Merge PR DefinitelyTyped#72395 feat(react-highcharts): add missing props & methods, resolve attw by @hkleungai
1 parent f8726a8 commit 459d0ed

File tree

3 files changed

+59
-27
lines changed

3 files changed

+59
-27
lines changed

‎attw.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@
253253
"react-dynamic-number",
254254
"react-embed-gist",
255255
"react-facebook-login",
256-
"react-highcharts",
257256
"react-highlight",
258257
"react-holder",
259258
"react-howler",
Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,44 @@
11
import * as Highcharts from "highcharts";
22
import * as React from "react";
33

4-
/**
5-
* Props for ReactHighcharts component.
6-
*/
7-
interface ReactHighchartsProps {
4+
declare namespace ReactHighcharts {
85
/**
9-
* Highcharts configuration options.
6+
* Props for ReactHighcharts component.
107
*/
11-
config: Highcharts.Options;
12-
/**
13-
* @param after-render callback.
14-
*/
15-
callback?(chart: Highcharts.ChartObject): void;
8+
interface ReactHighchartsProps {
9+
/**
10+
* Highcharts configuration options.
11+
*/
12+
config: Highcharts.Options;
1613

17-
/**
18-
* Chart will not rerender if the config is referentially equal to previous and this property is true
19-
*/
20-
isPureConfig?: boolean | undefined;
14+
/**
15+
* Chart will not rerender if the config is referentially equal to previous and this property is true
16+
*/
17+
isPureConfig?: boolean | undefined;
18+
19+
neverReflow?: boolean | undefined;
20+
21+
/**
22+
* after-render callback.
23+
*/
24+
callback?: ((chart: Highcharts.ChartObject) => void) | undefined;
25+
26+
/**
27+
* Passing properties to the wrapping DOM element
28+
*/
29+
domProps?: Partial<React.JSX.IntrinsicElements["div"]> | undefined;
30+
}
31+
32+
function withHighcharts(Highcharts: Highcharts.Static): typeof ReactHighcharts;
2133
}
2234

2335
/**
2436
* React interface for highcharts.
2537
*/
26-
declare class ReactHighcharts extends React.Component<ReactHighchartsProps> {
38+
declare class ReactHighcharts extends React.Component<ReactHighcharts.ReactHighchartsProps> {
39+
static chartType: string;
2740
static Highcharts: Highcharts.Static;
41+
static displayName: string;
2842
}
2943

30-
export default ReactHighcharts;
44+
export = ReactHighcharts;

‎types/react-highcharts/react-highcharts-tests.tsx‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,35 @@ import * as Highcharts from "highcharts";
22
import * as React from "react";
33
import ReactHighcharts from "react-highcharts";
44

5-
const config: Highcharts.Options = {};
5+
// @ts-ignore - `props.config` is required
6+
<ReactHighcharts />;
67

7-
function callback(chart: Highcharts.ChartObject): void {}
8+
// With required props
9+
<ReactHighcharts config={{}} />;
810

9-
const isPureConfig = true;
11+
// With optional props
12+
<ReactHighcharts
13+
config={{}}
14+
isPureConfig={true}
15+
neverReflow={true}
16+
callback={(chart) => {
17+
// $ExpectType ChartObject
18+
chart;
19+
}}
20+
domProps={{
21+
className: "div-classname",
22+
}}
23+
/>;
1024

11-
export const _ = () => (
12-
<>
13-
<ReactHighcharts config={config} />
14-
<ReactHighcharts config={config} callback={callback} />
15-
<ReactHighcharts config={config} callback={callback} isPureConfig={isPureConfig} />
16-
</>
17-
);
25+
// $ExpectType string
26+
ReactHighcharts.chartType;
27+
28+
// $ExpectType Static
29+
ReactHighcharts.Highcharts;
30+
31+
// $ExpectType string
32+
ReactHighcharts.displayName;
33+
34+
// $ExpectType typeof ReactHighcharts
35+
const AnotherReactHighcharts = ReactHighcharts.withHighcharts(ReactHighcharts.Highcharts);
36+
<AnotherReactHighcharts config={{}} />;

0 commit comments

Comments
 (0)