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

fix: compatability with react 16 typings #987

Merged
merged 1 commit into from
Jan 13, 2022
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"commit": "cz",
"release": "standard-version",
"cleanPublish": "yarn test && clean-publish",
"enableGitHooks": "simple-git-hooks"
"updateGitHooks": "simple-git-hooks"
},
"dependencies": {},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/chart.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CanvasHTMLAttributes, ForwardedRef, ReactNode } from 'react';
import type { CanvasHTMLAttributes, MutableRefObject, ReactNode } from 'react';
import type {
Chart,
ChartType,
Expand All @@ -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>,
Expand Down
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ForwardedRef, MouseEvent } from 'react';
import type { MouseEvent } from 'react';
import type {
ChartType,
ChartData,
Expand All @@ -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) {
Expand Down
34 changes: 0 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3371,14 +3371,6 @@
"@typescript-eslint/typescript-estree" "5.8.0"
debug "^4.3.2"

"@typescript-eslint/[email protected]":
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/[email protected]":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.0.tgz#2371095b4fa4c7be6a80b380f4e1b49c715e16f4"
Expand All @@ -3387,29 +3379,11 @@
"@typescript-eslint/types" "5.8.0"
"@typescript-eslint/visitor-keys" "5.8.0"

"@typescript-eslint/[email protected]":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.7.0.tgz#2d4cae0105ba7d08bffa69698197a762483ebcbe"
integrity sha512-5AeYIF5p2kAneIpnLFve8g50VyAjq7udM7ApZZ9JYjdPjkz0LvODfuSHIDUVnIuUoxafoWzpFyU7Sqbxgi79mA==

"@typescript-eslint/[email protected]":
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/[email protected]":
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/[email protected]":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.0.tgz#900469ba9d5a37f4482b014ecce4a5dbb86cb4dd"
Expand All @@ -3423,14 +3397,6 @@
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
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/[email protected]":
version "5.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.0.tgz#22d4ed96fe2451135299239feedb9fe1dcec780c"
Expand Down