Skip to content

Commit 06f9ffb

Browse files
authored
fix: pass Plugin TType down to hooks chart arg (#11569)
1 parent 93a5b84 commit 06f9ffb

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/types/index.d.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -829,37 +829,37 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
829829
* @param {object} options - The plugin options.
830830
* @since 3.0.0
831831
*/
832-
install?(chart: Chart, args: EmptyObject, options: O): void;
832+
install?(chart: Chart<TType>, args: EmptyObject, options: O): void;
833833
/**
834834
* @desc Called when a plugin is starting. This happens when chart is created or plugin is enabled.
835835
* @param {Chart} chart - The chart instance.
836836
* @param {object} args - The call arguments.
837837
* @param {object} options - The plugin options.
838838
* @since 3.0.0
839839
*/
840-
start?(chart: Chart, args: EmptyObject, options: O): void;
840+
start?(chart: Chart<TType>, args: EmptyObject, options: O): void;
841841
/**
842842
* @desc Called when a plugin stopping. This happens when chart is destroyed or plugin is disabled.
843843
* @param {Chart} chart - The chart instance.
844844
* @param {object} args - The call arguments.
845845
* @param {object} options - The plugin options.
846846
* @since 3.0.0
847847
*/
848-
stop?(chart: Chart, args: EmptyObject, options: O): void;
848+
stop?(chart: Chart<TType>, args: EmptyObject, options: O): void;
849849
/**
850850
* @desc Called before initializing `chart`.
851851
* @param {Chart} chart - The chart instance.
852852
* @param {object} args - The call arguments.
853853
* @param {object} options - The plugin options.
854854
*/
855-
beforeInit?(chart: Chart, args: EmptyObject, options: O): void;
855+
beforeInit?(chart: Chart<TType>, args: EmptyObject, options: O): void;
856856
/**
857857
* @desc Called after `chart` has been initialized and before the first update.
858858
* @param {Chart} chart - The chart instance.
859859
* @param {object} args - The call arguments.
860860
* @param {object} options - The plugin options.
861861
*/
862-
afterInit?(chart: Chart, args: EmptyObject, options: O): void;
862+
afterInit?(chart: Chart<TType>, args: EmptyObject, options: O): void;
863863
/**
864864
* @desc Called before updating `chart`. If any plugin returns `false`, the update
865865
* is cancelled (and thus subsequent render(s)) until another `update` is triggered.
@@ -869,7 +869,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
869869
* @param {object} options - The plugin options.
870870
* @returns {boolean} `false` to cancel the chart update.
871871
*/
872-
beforeUpdate?(chart: Chart, args: { mode: UpdateMode, cancelable: true }, options: O): boolean | void;
872+
beforeUpdate?(chart: Chart<TType>, args: { mode: UpdateMode, cancelable: true }, options: O): boolean | void;
873873
/**
874874
* @desc Called after `chart` has been updated and before rendering. Note that this
875875
* hook will not be called if the chart update has been previously cancelled.
@@ -878,23 +878,23 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
878878
* @param {UpdateMode} args.mode - The update mode
879879
* @param {object} options - The plugin options.
880880
*/
881-
afterUpdate?(chart: Chart, args: { mode: UpdateMode }, options: O): void;
881+
afterUpdate?(chart: Chart<TType>, args: { mode: UpdateMode }, options: O): void;
882882
/**
883883
* @desc Called during the update process, before any chart elements have been created.
884884
* This can be used for data decimation by changing the data array inside a dataset.
885885
* @param {Chart} chart - The chart instance.
886886
* @param {object} args - The call arguments.
887887
* @param {object} options - The plugin options.
888888
*/
889-
beforeElementsUpdate?(chart: Chart, args: EmptyObject, options: O): void;
889+
beforeElementsUpdate?(chart: Chart<TType>, args: EmptyObject, options: O): void;
890890
/**
891891
* @desc Called during chart reset
892892
* @param {Chart} chart - The chart instance.
893893
* @param {object} args - The call arguments.
894894
* @param {object} options - The plugin options.
895895
* @since version 3.0.0
896896
*/
897-
reset?(chart: Chart, args: EmptyObject, options: O): void;
897+
reset?(chart: Chart<TType>, args: EmptyObject, options: O): void;
898898
/**
899899
* @desc Called before updating the `chart` datasets. If any plugin returns `false`,
900900
* the datasets update is cancelled until another `update` is triggered.
@@ -905,7 +905,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
905905
* @returns {boolean} false to cancel the datasets update.
906906
* @since version 2.1.5
907907
*/
908-
beforeDatasetsUpdate?(chart: Chart, args: { mode: UpdateMode }, options: O): boolean | void;
908+
beforeDatasetsUpdate?(chart: Chart<TType>, args: { mode: UpdateMode }, options: O): boolean | void;
909909
/**
910910
* @desc Called after the `chart` datasets have been updated. Note that this hook
911911
* will not be called if the datasets update has been previously cancelled.
@@ -915,7 +915,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
915915
* @param {object} options - The plugin options.
916916
* @since version 2.1.5
917917
*/
918-
afterDatasetsUpdate?(chart: Chart, args: { mode: UpdateMode, cancelable: true }, options: O): void;
918+
afterDatasetsUpdate?(chart: Chart<TType>, args: { mode: UpdateMode, cancelable: true }, options: O): void;
919919
/**
920920
* @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
921921
* returns `false`, the datasets update is cancelled until another `update` is triggered.
@@ -927,7 +927,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
927927
* @param {object} options - The plugin options.
928928
* @returns {boolean} `false` to cancel the chart datasets drawing.
929929
*/
930-
beforeDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: true }, options: O): boolean | void;
930+
beforeDatasetUpdate?(chart: Chart<TType>, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: true }, options: O): boolean | void;
931931
/**
932932
* @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
933933
* that this hook will not be called if the datasets update has been previously cancelled.
@@ -938,7 +938,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
938938
* @param {UpdateMode} args.mode - The update mode.
939939
* @param {object} options - The plugin options.
940940
*/
941-
afterDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: false }, options: O): void;
941+
afterDatasetUpdate?(chart: Chart<TType>, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: false }, options: O): void;
942942
/**
943943
* @desc Called before laying out `chart`. If any plugin returns `false`,
944944
* the layout update is cancelled until another `update` is triggered.
@@ -947,47 +947,47 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
947947
* @param {object} options - The plugin options.
948948
* @returns {boolean} `false` to cancel the chart layout.
949949
*/
950-
beforeLayout?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
950+
beforeLayout?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
951951
/**
952952
* @desc Called before scale data limits are calculated. This hook is called separately for each scale in the chart.
953953
* @param {Chart} chart - The chart instance.
954954
* @param {object} args - The call arguments.
955955
* @param {Scale} args.scale - The scale.
956956
* @param {object} options - The plugin options.
957957
*/
958-
beforeDataLimits?(chart: Chart, args: { scale: Scale }, options: O): void;
958+
beforeDataLimits?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
959959
/**
960960
* @desc Called after scale data limits are calculated. This hook is called separately for each scale in the chart.
961961
* @param {Chart} chart - The chart instance.
962962
* @param {object} args - The call arguments.
963963
* @param {Scale} args.scale - The scale.
964964
* @param {object} options - The plugin options.
965965
*/
966-
afterDataLimits?(chart: Chart, args: { scale: Scale }, options: O): void;
966+
afterDataLimits?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
967967
/**
968968
* @desc Called before scale builds its ticks. This hook is called separately for each scale in the chart.
969969
* @param {Chart} chart - The chart instance.
970970
* @param {object} args - The call arguments.
971971
* @param {Scale} args.scale - The scale.
972972
* @param {object} options - The plugin options.
973973
*/
974-
beforeBuildTicks?(chart: Chart, args: { scale: Scale }, options: O): void;
974+
beforeBuildTicks?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
975975
/**
976976
* @desc Called after scale has build its ticks. This hook is called separately for each scale in the chart.
977977
* @param {Chart} chart - The chart instance.
978978
* @param {object} args - The call arguments.
979979
* @param {Scale} args.scale - The scale.
980980
* @param {object} options - The plugin options.
981981
*/
982-
afterBuildTicks?(chart: Chart, args: { scale: Scale }, options: O): void;
982+
afterBuildTicks?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
983983
/**
984984
* @desc Called after the `chart` has been laid out. Note that this hook will not
985985
* be called if the layout update has been previously cancelled.
986986
* @param {Chart} chart - The chart instance.
987987
* @param {object} args - The call arguments.
988988
* @param {object} options - The plugin options.
989989
*/
990-
afterLayout?(chart: Chart, args: EmptyObject, options: O): void;
990+
afterLayout?(chart: Chart<TType>, args: EmptyObject, options: O): void;
991991
/**
992992
* @desc Called before rendering `chart`. If any plugin returns `false`,
993993
* the rendering is cancelled until another `render` is triggered.
@@ -996,15 +996,15 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
996996
* @param {object} options - The plugin options.
997997
* @returns {boolean} `false` to cancel the chart rendering.
998998
*/
999-
beforeRender?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
999+
beforeRender?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
10001000
/**
10011001
* @desc Called after the `chart` has been fully rendered (and animation completed). Note
10021002
* that this hook will not be called if the rendering has been previously cancelled.
10031003
* @param {Chart} chart - The chart instance.
10041004
* @param {object} args - The call arguments.
10051005
* @param {object} options - The plugin options.
10061006
*/
1007-
afterRender?(chart: Chart, args: EmptyObject, options: O): void;
1007+
afterRender?(chart: Chart<TType>, args: EmptyObject, options: O): void;
10081008
/**
10091009
* @desc Called before drawing `chart` at every animation frame. If any plugin returns `false`,
10101010
* the frame drawing is cancelled untilanother `render` is triggered.
@@ -1013,15 +1013,15 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10131013
* @param {object} options - The plugin options.
10141014
* @returns {boolean} `false` to cancel the chart drawing.
10151015
*/
1016-
beforeDraw?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
1016+
beforeDraw?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
10171017
/**
10181018
* @desc Called after the `chart` has been drawn. Note that this hook will not be called
10191019
* if the drawing has been previously cancelled.
10201020
* @param {Chart} chart - The chart instance.
10211021
* @param {object} args - The call arguments.
10221022
* @param {object} options - The plugin options.
10231023
*/
1024-
afterDraw?(chart: Chart, args: EmptyObject, options: O): void;
1024+
afterDraw?(chart: Chart<TType>, args: EmptyObject, options: O): void;
10251025
/**
10261026
* @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
10271027
* the datasets drawing is cancelled until another `render` is triggered.
@@ -1030,15 +1030,15 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10301030
* @param {object} options - The plugin options.
10311031
* @returns {boolean} `false` to cancel the chart datasets drawing.
10321032
*/
1033-
beforeDatasetsDraw?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
1033+
beforeDatasetsDraw?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
10341034
/**
10351035
* @desc Called after the `chart` datasets have been drawn. Note that this hook
10361036
* will not be called if the datasets drawing has been previously cancelled.
10371037
* @param {Chart} chart - The chart instance.
10381038
* @param {object} args - The call arguments.
10391039
* @param {object} options - The plugin options.
10401040
*/
1041-
afterDatasetsDraw?(chart: Chart, args: EmptyObject, options: O, cancelable: false): void;
1041+
afterDatasetsDraw?(chart: Chart<TType>, args: EmptyObject, options: O, cancelable: false): void;
10421042
/**
10431043
* @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
10441044
* are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
@@ -1050,7 +1050,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10501050
* @param {object} options - The plugin options.
10511051
* @returns {boolean} `false` to cancel the chart datasets drawing.
10521052
*/
1053-
beforeDatasetDraw?(chart: Chart, args: { index: number; meta: ChartMeta }, options: O): boolean | void;
1053+
beforeDatasetDraw?(chart: Chart<TType>, args: { index: number; meta: ChartMeta }, options: O): boolean | void;
10541054
/**
10551055
* @desc Called after the `chart` datasets at the given `args.index` have been drawn
10561056
* (datasets are drawn in the reverse order). Note that this hook will not be called
@@ -1061,7 +1061,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10611061
* @param {object} args.meta - The dataset metadata.
10621062
* @param {object} options - The plugin options.
10631063
*/
1064-
afterDatasetDraw?(chart: Chart, args: { index: number; meta: ChartMeta }, options: O): void;
1064+
afterDatasetDraw?(chart: Chart<TType>, args: { index: number; meta: ChartMeta }, options: O): void;
10651065
/**
10661066
* @desc Called before processing the specified `event`. If any plugin returns `false`,
10671067
* the event will be discarded.
@@ -1072,7 +1072,7 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10721072
* @param {boolean} args.inChartArea - The event position is inside chartArea
10731073
* @param {object} options - The plugin options.
10741074
*/
1075-
beforeEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, cancelable: true, inChartArea: boolean }, options: O): boolean | void;
1075+
beforeEvent?(chart: Chart<TType>, args: { event: ChartEvent, replay: boolean, cancelable: true, inChartArea: boolean }, options: O): boolean | void;
10761076
/**
10771077
* @desc Called after the `event` has been consumed. Note that this hook
10781078
* will not be called if the `event` has been previously discarded.
@@ -1084,37 +1084,37 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
10841084
* @param {boolean} [args.changed] - Set to true if the plugin needs a render. Should only be changed to true, because this args object is passed through all plugins.
10851085
* @param {object} options - The plugin options.
10861086
*/
1087-
afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, changed?: boolean, cancelable: false, inChartArea: boolean }, options: O): void;
1087+
afterEvent?(chart: Chart<TType>, args: { event: ChartEvent, replay: boolean, changed?: boolean, cancelable: false, inChartArea: boolean }, options: O): void;
10881088
/**
10891089
* @desc Called after the chart as been resized.
10901090
* @param {Chart} chart - The chart instance.
10911091
* @param {object} args - The call arguments.
10921092
* @param {number} args.size - The new canvas display size (eq. canvas.style width & height).
10931093
* @param {object} options - The plugin options.
10941094
*/
1095-
resize?(chart: Chart, args: { size: { width: number, height: number } }, options: O): void;
1095+
resize?(chart: Chart<TType>, args: { size: { width: number, height: number } }, options: O): void;
10961096
/**
10971097
* Called before the chart is being destroyed.
10981098
* @param {Chart} chart - The chart instance.
10991099
* @param {object} args - The call arguments.
11001100
* @param {object} options - The plugin options.
11011101
*/
1102-
beforeDestroy?(chart: Chart, args: EmptyObject, options: O): void;
1102+
beforeDestroy?(chart: Chart<TType>, args: EmptyObject, options: O): void;
11031103
/**
11041104
* Called after the chart has been destroyed.
11051105
* @param {Chart} chart - The chart instance.
11061106
* @param {object} args - The call arguments.
11071107
* @param {object} options - The plugin options.
11081108
*/
1109-
afterDestroy?(chart: Chart, args: EmptyObject, options: O): void;
1109+
afterDestroy?(chart: Chart<TType>, args: EmptyObject, options: O): void;
11101110
/**
11111111
* Called after chart is destroyed on all plugins that were installed for that chart. This hook is also invoked for disabled plugins (options === false).
11121112
* @param {Chart} chart - The chart instance.
11131113
* @param {object} args - The call arguments.
11141114
* @param {object} options - The plugin options.
11151115
* @since 3.0.0
11161116
*/
1117-
uninstall?(chart: Chart, args: EmptyObject, options: O): void;
1117+
uninstall?(chart: Chart<TType>, args: EmptyObject, options: O): void;
11181118

11191119
/**
11201120
* Default options used in the plugin

0 commit comments

Comments
 (0)