Skip to content

Commit 4a01054

Browse files
authored
fix: compatability with react 16 typings (#987)
fix #870
1 parent 96e66c8 commit 4a01054

File tree

5 files changed

+11
-39
lines changed

5 files changed

+11
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"commit": "cz",
4040
"release": "standard-version",
4141
"cleanPublish": "yarn test && clean-publish",
42-
"enableGitHooks": "simple-git-hooks"
42+
"updateGitHooks": "simple-git-hooks"
4343
},
4444
"dependencies": {},
4545
"peerDependencies": {

src/chart.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, { useEffect, useRef, forwardRef } from 'react';
2-
import type { ForwardedRef } from 'react';
32
import { Chart as ChartJS } from 'chart.js';
43
import type { ChartType, DefaultDataPoint } from 'chart.js';
54

6-
import type { ChartProps, TypedChartComponent } from './types';
5+
import type { ForwardedRef, ChartProps, TypedChartComponent } from './types';
76
import {
87
reforwardRef,
98
cloneData,

src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CanvasHTMLAttributes, ForwardedRef, ReactNode } from 'react';
1+
import type { CanvasHTMLAttributes, MutableRefObject, ReactNode } from 'react';
22
import type {
33
Chart,
44
ChartType,
@@ -8,6 +8,11 @@ import type {
88
Plugin,
99
} from 'chart.js';
1010

11+
export type ForwardedRef<T> =
12+
| ((instance: T | null) => void)
13+
| MutableRefObject<T | null>
14+
| null;
15+
1116
export interface ChartProps<
1217
TType extends ChartType = ChartType,
1318
TData = DefaultDataPoint<TType>,

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ForwardedRef, MouseEvent } from 'react';
1+
import type { MouseEvent } from 'react';
22
import type {
33
ChartType,
44
ChartData,
@@ -8,6 +8,8 @@ import type {
88
Chart,
99
} from 'chart.js';
1010

11+
import type { ForwardedRef } from './types';
12+
1113
const defaultDatasetIdKey = 'label';
1214

1315
export function reforwardRef<T>(ref: ForwardedRef<T>, value: T) {

yarn.lock

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,14 +3371,6 @@
33713371
"@typescript-eslint/typescript-estree" "5.8.0"
33723372
debug "^4.3.2"
33733373

3374-
"@typescript-eslint/scope-manager@5.7.0":
3375-
version "5.7.0"
3376-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.7.0.tgz#70adf960e5a58994ad50438ba60d98ecadd79452"
3377-
integrity sha512-7mxR520DGq5F7sSSgM0HSSMJ+TFUymOeFRMfUfGFAVBv8BR+Jv1vHgAouYUvWRZeszVBJlLcc9fDdktxb5kmxA==
3378-
dependencies:
3379-
"@typescript-eslint/types" "5.7.0"
3380-
"@typescript-eslint/visitor-keys" "5.7.0"
3381-
33823374
"@typescript-eslint/scope-manager@5.8.0":
33833375
version "5.8.0"
33843376
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.0.tgz#2371095b4fa4c7be6a80b380f4e1b49c715e16f4"
@@ -3387,29 +3379,11 @@
33873379
"@typescript-eslint/types" "5.8.0"
33883380
"@typescript-eslint/visitor-keys" "5.8.0"
33893381

3390-
"@typescript-eslint/types@5.7.0":
3391-
version "5.7.0"
3392-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.7.0.tgz#2d4cae0105ba7d08bffa69698197a762483ebcbe"
3393-
integrity sha512-5AeYIF5p2kAneIpnLFve8g50VyAjq7udM7ApZZ9JYjdPjkz0LvODfuSHIDUVnIuUoxafoWzpFyU7Sqbxgi79mA==
3394-
33953382
"@typescript-eslint/types@5.8.0":
33963383
version "5.8.0"
33973384
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.8.0.tgz#e7fa74ec35d9dbe3560d039d3d8734986c3971e0"
33983385
integrity sha512-LdCYOqeqZWqCMOmwFnum6YfW9F3nKuxJiR84CdIRN5nfHJ7gyvGpXWqL/AaW0k3Po0+wm93ARAsOdzlZDPCcXg==
33993386

3400-
"@typescript-eslint/typescript-estree@5.7.0":
3401-
version "5.7.0"
3402-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.7.0.tgz#968fad899050ccce4f08a40cd5fabc0798525006"
3403-
integrity sha512-aO1Ql+izMrTnPj5aFFlEJkpD4jRqC4Gwhygu2oHK2wfVQpmOPbyDSveJ+r/NQo+PWV43M6uEAeLVbTi09dFLhg==
3404-
dependencies:
3405-
"@typescript-eslint/types" "5.7.0"
3406-
"@typescript-eslint/visitor-keys" "5.7.0"
3407-
debug "^4.3.2"
3408-
globby "^11.0.4"
3409-
is-glob "^4.0.3"
3410-
semver "^7.3.5"
3411-
tsutils "^3.21.0"
3412-
34133387
"@typescript-eslint/typescript-estree@5.8.0":
34143388
version "5.8.0"
34153389
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.0.tgz#900469ba9d5a37f4482b014ecce4a5dbb86cb4dd"
@@ -3423,14 +3397,6 @@
34233397
semver "^7.3.5"
34243398
tsutils "^3.21.0"
34253399

3426-
"@typescript-eslint/visitor-keys@5.7.0":
3427-
version "5.7.0"
3428-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.7.0.tgz#e05164239eb7cb8aa9fa06c516ede480ce260178"
3429-
integrity sha512-hdohahZ4lTFcglZSJ3DGdzxQHBSxsLVqHzkiOmKi7xVAWC4y2c1bIMKmPJSrA4aOEoRUPOKQ87Y/taC7yVHpFg==
3430-
dependencies:
3431-
"@typescript-eslint/types" "5.7.0"
3432-
eslint-visitor-keys "^3.0.0"
3433-
34343400
"@typescript-eslint/visitor-keys@5.8.0":
34353401
version "5.8.0"
34363402
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.0.tgz#22d4ed96fe2451135299239feedb9fe1dcec780c"

0 commit comments

Comments
 (0)