From 9a6717196491ddab58c515256b11b74ef43cb8ec Mon Sep 17 00:00:00 2001
From: dangreen <danon0404@gmail.com>
Date: Thu, 13 Jan 2022 18:19:38 +0700
Subject: [PATCH] fix: compatability with react 16 typings

fix #870
---
 package.json  |  2 +-
 src/chart.tsx |  3 +--
 src/types.ts  |  7 ++++++-
 src/utils.ts  |  4 +++-
 yarn.lock     | 34 ----------------------------------
 5 files changed, 11 insertions(+), 39 deletions(-)

diff --git a/package.json b/package.json
index 341eb992e..bbd193368 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
     "commit": "cz",
     "release": "standard-version",
     "cleanPublish": "yarn test && clean-publish",
-    "enableGitHooks": "simple-git-hooks"
+    "updateGitHooks": "simple-git-hooks"
   },
   "dependencies": {},
   "peerDependencies": {
diff --git a/src/chart.tsx b/src/chart.tsx
index 635c03bfb..08df13418 100644
--- a/src/chart.tsx
+++ b/src/chart.tsx
@@ -1,9 +1,8 @@
 import React, { useEffect, useRef, forwardRef } from 'react';
-import type { ForwardedRef } from 'react';
 import { Chart as ChartJS } from 'chart.js';
 import type { ChartType, DefaultDataPoint } from 'chart.js';
 
-import type { ChartProps, TypedChartComponent } from './types';
+import type { ForwardedRef, ChartProps, TypedChartComponent } from './types';
 import {
   reforwardRef,
   cloneData,
diff --git a/src/types.ts b/src/types.ts
index e7f5a1950..38f5083f2 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,4 +1,4 @@
-import type { CanvasHTMLAttributes, ForwardedRef, ReactNode } from 'react';
+import type { CanvasHTMLAttributes, MutableRefObject, ReactNode } from 'react';
 import type {
   Chart,
   ChartType,
@@ -8,6 +8,11 @@ import type {
   Plugin,
 } from 'chart.js';
 
+export type ForwardedRef<T> =
+  | ((instance: T | null) => void)
+  | MutableRefObject<T | null>
+  | null;
+
 export interface ChartProps<
   TType extends ChartType = ChartType,
   TData = DefaultDataPoint<TType>,
diff --git a/src/utils.ts b/src/utils.ts
index da5b18bdf..53c44a895 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,4 +1,4 @@
-import type { ForwardedRef, MouseEvent } from 'react';
+import type { MouseEvent } from 'react';
 import type {
   ChartType,
   ChartData,
@@ -8,6 +8,8 @@ import type {
   Chart,
 } from 'chart.js';
 
+import type { ForwardedRef } from './types';
+
 const defaultDatasetIdKey = 'label';
 
 export function reforwardRef<T>(ref: ForwardedRef<T>, value: T) {
diff --git a/yarn.lock b/yarn.lock
index bee6f9c16..e9bb2c064 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3371,14 +3371,6 @@
     "@typescript-eslint/typescript-estree" "5.8.0"
     debug "^4.3.2"
 
-"@typescript-eslint/scope-manager@5.7.0":
-  version "5.7.0"
-  resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.7.0.tgz#70adf960e5a58994ad50438ba60d98ecadd79452"
-  integrity sha512-7mxR520DGq5F7sSSgM0HSSMJ+TFUymOeFRMfUfGFAVBv8BR+Jv1vHgAouYUvWRZeszVBJlLcc9fDdktxb5kmxA==
-  dependencies:
-    "@typescript-eslint/types" "5.7.0"
-    "@typescript-eslint/visitor-keys" "5.7.0"
-
 "@typescript-eslint/scope-manager@5.8.0":
   version "5.8.0"
   resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.0.tgz#2371095b4fa4c7be6a80b380f4e1b49c715e16f4"
@@ -3387,29 +3379,11 @@
     "@typescript-eslint/types" "5.8.0"
     "@typescript-eslint/visitor-keys" "5.8.0"
 
-"@typescript-eslint/types@5.7.0":
-  version "5.7.0"
-  resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.7.0.tgz#2d4cae0105ba7d08bffa69698197a762483ebcbe"
-  integrity sha512-5AeYIF5p2kAneIpnLFve8g50VyAjq7udM7ApZZ9JYjdPjkz0LvODfuSHIDUVnIuUoxafoWzpFyU7Sqbxgi79mA==
-
 "@typescript-eslint/types@5.8.0":
   version "5.8.0"
   resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.8.0.tgz#e7fa74ec35d9dbe3560d039d3d8734986c3971e0"
   integrity sha512-LdCYOqeqZWqCMOmwFnum6YfW9F3nKuxJiR84CdIRN5nfHJ7gyvGpXWqL/AaW0k3Po0+wm93ARAsOdzlZDPCcXg==
 
-"@typescript-eslint/typescript-estree@5.7.0":
-  version "5.7.0"
-  resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.7.0.tgz#968fad899050ccce4f08a40cd5fabc0798525006"
-  integrity sha512-aO1Ql+izMrTnPj5aFFlEJkpD4jRqC4Gwhygu2oHK2wfVQpmOPbyDSveJ+r/NQo+PWV43M6uEAeLVbTi09dFLhg==
-  dependencies:
-    "@typescript-eslint/types" "5.7.0"
-    "@typescript-eslint/visitor-keys" "5.7.0"
-    debug "^4.3.2"
-    globby "^11.0.4"
-    is-glob "^4.0.3"
-    semver "^7.3.5"
-    tsutils "^3.21.0"
-
 "@typescript-eslint/typescript-estree@5.8.0":
   version "5.8.0"
   resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.0.tgz#900469ba9d5a37f4482b014ecce4a5dbb86cb4dd"
@@ -3423,14 +3397,6 @@
     semver "^7.3.5"
     tsutils "^3.21.0"
 
-"@typescript-eslint/visitor-keys@5.7.0":
-  version "5.7.0"
-  resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.7.0.tgz#e05164239eb7cb8aa9fa06c516ede480ce260178"
-  integrity sha512-hdohahZ4lTFcglZSJ3DGdzxQHBSxsLVqHzkiOmKi7xVAWC4y2c1bIMKmPJSrA4aOEoRUPOKQ87Y/taC7yVHpFg==
-  dependencies:
-    "@typescript-eslint/types" "5.7.0"
-    eslint-visitor-keys "^3.0.0"
-
 "@typescript-eslint/visitor-keys@5.8.0":
   version "5.8.0"
   resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.0.tgz#22d4ed96fe2451135299239feedb9fe1dcec780c"